PHP idate() Function
What is a idate Function?
Explanation
The "idate()" function is used to format a local time/date as integer.
Syntax:
idate(format,timestamp)
In the above syntax the parameters for the function are "format", which specifies the format of the output, timestamp, is a default field which specifies date or time to be formatted, if not specified it will take default Current Time.
The following are the format parameters for idate() function. | Format | Description |
| 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 DST (daylight saving time) is activated, 0 otherwise |
| L | returns 1 for leap year, 0 otherwise |
| m | Month number |
| s | Seconds |
| t | Days in current month |
| U | Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) |
| w | Day of the week (Sunday=0) |
| W | ISO-8601 week number of year (week starts on Monday) |
| y | Year (1 or 2 digits) |
| Y | Year (4 digits) |
| z | Day of the year |
| Z | Timezone offset in seconds |
Example :
<?php
$timestamp = strtotime('1st February 2006'); //1072915200
// this prints the year in a two digit format
// however, as this would start with a "0", it
// only prints "6"
echo idate('y', $timestamp);
?>
Result :
6
In the above example the format 'y' returns the value of a year in a two digit format, since the year specified is "2006", first digit is 0, it displays 6. Note :
(PHP 5)