Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP idate() Function

PHP idate() Function

PHP Date/Time PHP Date/Time Reference Manual

Example

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

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

Run Example »


Definition and Usage

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

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

Syntax

idate(

format,timestamp);

Parameters Description
format Required. Specifies how to format 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, 0 otherwise
  • L - Returns 1 if it is a leap year, 0 otherwise
  • m - Month number
  • s - Seconds
  • t - Total number of days in the month
  • U - Seconds 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 of the ISO-8601 year, with each week starting on Monday
  • y - Year (1 or 2 digits)
  • Y - Year (4 digits)
  • z - Day of the year
  • Z - Time zone offset in seconds
  • | | *timestamp* | Optional. Specifies the Unix timestamp of the date/time to format. Defaults to the current time (time()). |

    Technical Details

    Return Value: Returns an integer formatted according to the specified format using the given timestamp format.
    PHP Version: 5+
    Changelog: PHP 5.1.0: E_STRICT and E_NOTICE time zone errors were added.

    PHP Date/Time PHP Date/Time Reference Manual