YouTip LogoYouTip

Func Date Date

[![Image 1: PHP Date/Time]( PHP Date/Time Reference Manual](\n\n## Example\n\nFormat the local date and time, and return a formatted date string:\n\n```php\n\n```\n\nOutput:\n\n```\n2018-01-31 22:09:35\n2018 Year 01 Month 31 Day 22 Hour 09 Minute 35 Second\n2018-01-18 08:08:08\n```\n\n* * *\n\n## Definition and Usage\n\nThe `date()` function formats the local date and time, and returns a formatted date string.\n\n## Syntax\n\n```php\ndate(_format, timestamp);\n```\n\nReturns a string generated by formatting the integer `timestamp` according to the given format string. If no timestamp is provided, the current local time is used. In other words, `timestamp` is optional, with a default value of `time()`.\n\n| Parameter | Description |\n| --- | --- |\n| _format_ | Required. Specifies the format of the output date string. The following characters can be used: * d - Day of the month (from 01 to 31) * D - Full textual representation of the day of the week (three letters) * j - Day of the month without leading zeros (1 to 31) * l ('L' in lowercase) - Full textual representation of the day of the week * N - ISO-8601 numeric representation of the day of the week (1 for Monday, 7 for Sunday) * S - English ordinal suffix for the day of the month (2 characters: st, nd, rd, or th. Used together with j) * w - Numeric representation of the day of the week (0 for Sunday, 6 for Saturday) * z - Day of the year (from 0 to 365) * W - Week number of the year in ISO-8601 format (each week starts on Monday) * F - Full textual representation of the month (January to December) * m - Numeric representation of the month (from 01 to 12) * M - Short textual representation of the month (three letters) * n - Numeric representation of the month without leading zeros (1 to 12) * t - Number of days in the given month * L - Whether it's a leap year (1 if leap year, 0 otherwise) * o - Year number in ISO-8601 standard * Y - Four-digit year representation * y - Two-digit year representation * a - Lowercase form: am or pm * A - Uppercase form: AM or PM * B - Swatch Internet Time (000 to 999) * g - 12-hour clock without leading zeros (1 to 12) * G - 24-hour clock without leading zeros (0 to 23) * h - 12-hour clock with leading zeros (01 to 12) * H - 24-hour clock with leading zeros (00 to 23) * i - Minutes with leading zeros (00 to 59) * s - Seconds with leading zeros (00 to 59) * u - Microseconds (new in PHP 5.2.2) * e - Time zone identifier (e.g., UTC, GMT, Atlantic/Azores) * I (uppercase i) - Whether the date is in daylight saving time (1 if DST, 0 otherwise) * O - Difference from Greenwich Mean Time (GMT), in hours (e.g., +0100) * P - Difference from GMT, in hours:minutes (new in PHP 5.1.3) * T - Abbreviated time zone (e.g., EST, MDT) * Z - Time zone offset in seconds. Western time zones have negative offsets (from -43200 to 50400) * c - ISO-8601 standard date (e.g., 2013-05-05T16:34:42+00:00) * r - RFC 2822 format date (e.g., Fri, 12 Apr 2013 12:01:05 +0200) * U - Seconds since Unix epoch (January 1, 1970, 00:00:00 GMT) Additionally, the following predefined constants can also be used (available since PHP 5.1.0): * DATE_ATOM - Atom format (e.g., 2013-04-12T15:52:01+00:00) * DATE_COOKIE - HTTP Cookie format (e.g., Friday, 12-Apr-13 15:52:01 UTC) * DATE_ISO8601 - ISO-8601 format (e.g., 2013-04-12T15:52:01+0000) * DATE_RFC822 - RFC 822 format (e.g., Fri, 12 Apr 13 15:52:01 +0000) * DATE_RFC850 - RFC 850 format (e.g., Friday, 12-Apr-13 15:52:01 UTC) * DATE_RFC1036 - RFC 1036 format (e.g., Fri, 12 Apr 13 15:52:01 +0000) * DATE_RFC1123 - RFC 1123 format (e.g., Fri, 12 Apr 2013 15:52:01 +0000) * DATE_RFC2822 - RFC 2822 format (Fri, 12 Apr 2013 15:52:01 +0000) * DATE_RFC3339 - Same as DATE_ATOM (available since PHP 5.1.3) * DATE_RSS - RSS format (Fri, 12 Aug 2013 15:52:01 +0000) * DATE_W3C - World Wide Web Consortium format (e.g., 2013-04-12T15:52:01+00:00) |\n\n| _timestamp_ | Optional. Specifies an integer Unix timestamp. Defaults to the current local time (`time()`). |\n\n## Technical Details\n\n| Return Value: | Returns a formatted date string on success, or reports an E_WARNING error and returns FALSE on failure. |\n| --- | --- |\n| PHP Version: | 4+ |\n| Changelog: | PHP 5.1.0: Added E_STRICT and E_NOTICE timezone errors. Valid timestamp range is from Friday, December 13, 1901, 20:45:54 GMT to Tuesday, January 19, 2038, 03:14:07 GMT. Versions prior to 5.1.0 had timestamp limits on some systems (e.g., Windows) ranging from January 1, 1970, to January 19, 2038. PHP 5.1.1: Added standard date/time format constants for specifying the `_format` parameter. |\n\n* * *\n\n[![Image 2: PHP Date/Time]( PHP Date/Time Reference Manual](
← Func Date GetdateFunc Date Timezone Set β†’