PHP idate()Functions

PHP Date/TimePHP Date/Time Reference Manual

Examples

Format local time/date as an integer. Test all the different formats:

<?php
echo idate("B") . "<br>";
echo idate("d") . "<br>";
echo idate("h") . "<br>";
echo idate("H") . "<br>";
echo idate("i") . "<br>";
echo idate("I") . "<br>";
echo idate("L") . "<br>";
echo idate("m") . "<br>";
echo idate("s") . "<br>";
echo idate("t") . "<br>";
echo idate("U") . "<br>";
echo idate("w") . "<br>";
echo idate("W") . "<br>";
echo idate("y") . "<br>";
echo idate("Y") . "<br>";
echo idate("z") . "<br>";
echo idate("Z") . "<br>";
?>

Run example »

Definition and Usage

The idate() function formats local time/date as an integer.

Note:The idate() function only accepts one character as the format parameter!

Syntax

idate(format,timestamp);

Parameter Description
format Required. Specifies how to return the result:
  • B - Swatch Beat/Internet Time
  • d - Day of the month
  • h - Hour (12-hour format)
  • H - Hour (24-hour format)
  • i - Minutes
  • I - Returns 1 if daylight saving time is enabled, otherwise 0
  • L - Returns 1 if it is a leap year, otherwise 0
  • m - Month number
  • s - Seconds
  • t - Total days in the current month
  • U - Seconds elapsed since the Unix epoch (January 1 1970 00:00:00 GMT), same as time()
  • w - Day of the week (Sunday is 0)
  • W - Week number in the ISO-8601 year, each week starts on Monday
  • y - Year (1 or 2 digits)
  • Y - Year (4 digits)
  • z - Day of the year
  • Z - Timezone offset in seconds
timestamp Optional. Specifies the Unix timestamp of the date/time to be formatted. Defaults to the current time (time()).

Technical Details

Return value: Returns the integer formatted according to the specifiedformatusing the giventimestampformat.
PHP Version: 5+
Changelog: PHP 5.1.0: Added E_STRICT and E_NOTICE timezone errors.


PHP Date/TimePHP Date/Time Reference Manual Other Extensions