PHP Time Format
The time format is set by
special control commands for the
date
function.
Here are these commands:
U– the number of seconds since January1,1970(i.e.,timestamp).z– the day of the year (starting from 0).Y– year,4digits.y- year, two digits.m– numeric representation of a month (with leading zeros).n– numeric representation of a month (without leading zeros).d– day of the month (with leading zeros).j– day of the month (without leading zeros).w– numeric representation of the day of the week (0for Sunday,1for Monday, etc.).h– hour in12-hour format.H– hour in24-hour format.i– minutes.s– seconds.L–1if it's a leap year,0otherwise.W– ISO-8601 week number of the year.t– number of days in the given month.
Any separators can be inserted between the commands (hyphens, colons, etc.).
Examples of Using date
<?php
// All examples are shown for the date 01.06.2013 at 12.23.59, Monday
echo date('Y'); // returns '2013'
echo date('y'); // returns '13'
echo date('m'); // returns '06' - month number
echo date('d'); // returns '01' - day of the month
echo date('j'); // returns '1' - day of the month (without leading zero)
echo date('w'); // returns '1' - Monday
echo date('H'); // returns '12' - hours
echo date('i'); // returns '23' - minutes
echo date('s'); // returns '59' - seconds
echo date('d-m-Y'); // returns '01-06-2013'
echo date('d.m.Y'); // returns '01.06.2013'
echo date('H:i:s d.m.Y'); // returns '12:23:59 01.06.2013'
?>
See Also
-
the
datefunction,
which formats a date