date
php
string date(string $format, [number $znacznik_czasu])The date() function returns a time formatted according to $format. It behaves like PHP's date() function. If the optional $znacznik_czasu argument is omitted, it uses the current Unix timestamp (as returned by time()). If $znacznik_czasu is not a number, the function returns false.
To format a date, use one or more of the characters in the following table as the $format argument.
The original table comes from http://www.php.net/manual/pl/function.date.php.
Use the following characters as text in the argument.
| Contents of | Description | Example return value |
|---|---|---|
| Day | ||
| d | Day of the month, two digits with leading zeros | 01 through 31 |
| D | Abbreviated English weekday name, three letters | Mon through Sun |
| j | Day of the month without leading zeros | 1 through 31 |
| l (lowercase 'L') | Full English name of the day of the week | Sunday through Saturday |
| N | ISO-8601 numeric representation of the day of the week | 1 (Monday) through 7 (Sunday) |
| S | English ordinal suffix for the day of the month, two characters | st, nd, rd or th. Works well with j |
| w | Numeric representation of the day of the week | 0 (Sunday) through 6 (Saturday) |
| z | Day of the year, starting at 0 | 0 through 365 |
| Week | ||
| W | ISO-8601 week number of the year; weeks start on Monday | **Example:** 42 (the 42nd week of the year) |
| Month | ||
| F | Full English month name, such as January or March | January through December |
| m | Numeric representation of the month with leading zeros | 01 through 12 |
| M | Abbreviated English month name, three characters | Jan through Dec |
| n | Numeric representation of the month without leading zeros | 1 through 12 |
| t | Number of days in the month | 28 through 31 |
| Year | ||
| L | Whether the year is a leap year | 1 for a leap year, otherwise 0. |
| o | ISO-8601 week-numbering year. This is the same as Y, except when the ISO week number (W) belongs to the previous or following year. | Examples: 1999 or 2003 |
| Y | Full numeric representation of a year, four digits | Examples: 1999 or 2003 |
| y | Two-digit representation of a year | Examples: 99 or 03 |
| Time | ||
| a | Lowercase ante meridiem or post meridiem | am or pm |
| A | Uppercase ante meridiem or post meridiem | AM or PM |
| B | Swatch Internet Time | 000 through 999 |
| g | Hour in 12-hour format without leading zeros | 1 through 12 |
| G | Hour in 24-hour format without leading zeros | 0 through 23 |
| h | Hour in 12-hour format with leading zeros | 01 through 12 |
| H | Hour in 24-hour format with leading zeros | 00 through 23 |
| i | Minutes with leading zeros | 00 through 59 |
| s | Seconds with leading zeros | 00 through 59 |
| u | Microseconds | Example: 54321 |
| Time zone | ||
| e | Time zone identifier | Examples: UTC, GMT, Europe/Zagreb |
| I (uppercase i) | Whether daylight saving time is in effect | 1 during daylight saving time, otherwise 0. |
| O | Difference from Greenwich Mean Time (GMT) in hours | Example: +0200 |
| P | Difference from GMT with a colon between hours and minutes | Example: +02:00 |
| T | Time zone abbreviation | Examples: EST, MDT ... |
| Z | Time zone offset in seconds. Negative for time zones west of the prime meridian and positive for those east of it. | -43200 through 50400 |
| Full date/time | ||
| c | ISO 8601 date | 2004-02-12T15:19:21+00:00 |
| r | RFC 2822 formatted date | Example: Thu, 21 Dec 2000 16:01:07 +0200 |
| U | Seconds since the Unix epoch (1 January 1970, 00:00:00 GMT) | See also time() |
Examples:
Example | Result |
| date("Y-m-d H:i:s") | 2010-02-23 13:12:34 |
| date("l d F Y") | Tuesday 23 February 2010 |
| date("g:i a") | 1:12 pm |
| date("Y-m-d H:i:s", time()+3600) | 2010-02-23 14:12:34 |