PHP supports a whole host of date operations.
The strftime() function can be used to date/time into a given format.
The tokens used are:
| %a |
Abbreviated weekday name according
to the current locale |
| %A |
Full weekday name according to the
current locale |
| %b |
Abbreviated month name according
to the current locale |
| %B |
Full month name according to the
current locale |
| %c |
Preferred date and time representation
for the current locale |
| %C |
Century number (the year divided
by 100 and truncated to an integer, range 00 to 99) |
| %d |
Day of the month as a decimal number
(range 01 to 31) |
| %D |
Same as %m/%d/%y |
| %e |
Day of the month as a decimal number,
a single digit is preceded by a space (range ' 1' to '31')
|
| %g |
Like %G, but without the century.
|
| %G |
The 4- digit year corresponding
to the ISO week number (see %V). This has the same format
and value as %Y, except that if the ISO week number belongs
to the previous or next year, that year is used instead. |
| %h |
Same as %b |
| %H |
Hour as a decimal number using a
24-hour clock (range 00 to 23) |
| %I |
Hour as a decimal number using a
12- hour clock (range 01 to 12) |
| %j |
Day of the year as a decimal number
(range 001 to 366) |
| %m |
Month as a decimal number (range
01 to 12) |
| %M |
Minute as a decimal number |
| %n |
Newline character |
| %p |
Either `am' or `pm' according to
the given time value, or the corresponding strings for the
current locale |
| %r |
Time in a.m. and p.m. notation |
| %R |
Time in 24 hour notation |
| %S |
Second as a decimal number |
| %t |
Tab character |
| %T |
Current time, equal to %H:%M:%S
|
| %u |
Weekday as a decimal number [1,7],
with 1 representing Monday |
| %U |
Week number of the current year
as a decimal number, starting with the first Sunday as the
first day of the first week |
| %V |
The ISO 8601:1988 week number of
the current year as a decimal number, range 01 to 53, where
week 1 is the first week that has at least 4 days in the current
year, and with Monday as the first day of the week. (Use %G
or %g for the year component that corresponds to the week
number for the specified timestamp.) |
| %W |
Week number of the current year
as a decimal number, starting with the first Monday as the
first day of the first week |
| %w |
Day of the week as a decimal, Sunday
being 0 |
| %x |
Preferred date representation for
the current locale without the time |
| %X |
Preferred time representation for
the current locale without the date |
| %y |
Year as a decimal number without
a century (range 00 to 99) |
| %Y |
Year as a decimal number including
the century |
| %Z |
Time zone or name or abbreviation
|
For example using the %A (to display the current day), %H (to display
the current hour), and %M (to display the current minute):