Using Predefined Constants for Date Format

suggest change

We can use Predefined Constants for Date format in date() instead of the conventional date format strings since PHP 5.1.0.


Predefined Date Format Constants Available

DATE_ATOM - Atom (2016-07-22T14:50:01+00:00)

DATE_COOKIE - HTTP Cookies (Friday, 22-Jul-16 14:50:01 UTC)

DATE_RSS - RSS (Fri, 22 Jul 2016 14:50:01 +0000)

DATE_W3C - World Wide Web Consortium (2016-07-22T14:50:01+00:00)

DATE_ISO8601 - ISO-8601 (2016-07-22T14:50:01+0000)

DATE_RFC822 - RFC 822 (Fri, 22 Jul 16 14:50:01 +0000)

DATE_RFC850 - RFC 850 (Friday, 22-Jul-16 14:50:01 UTC)

DATE_RFC1036 - RFC 1036 (Fri, 22 Jul 16 14:50:01 +0000)

DATE_RFC1123 - RFC 1123 (Fri, 22 Jul 2016 14:50:01 +0000)

DATE_RFC2822 - RFC 2822 (Fri, 22 Jul 2016 14:50:01 +0000)

DATE_RFC3339 - Same as DATE_ATOM (2016-07-22T14:50:01+00:00)


Usage Examples

echo date(DATE_RFC822);
This will output: Fri, 22 Jul 16 14:50:01 +0000
echo date(DATE_ATOM,mktime(0,0,0,8,15,1947));
This will output: 1947-08-15T00:00:00+05:30

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Working with dates and time:
* Using Predefined Constants for Date Format

Table Of Contents
2 Arrays
4 Types
7 Working with dates and time
10 Cookies
14 JSON
15 SOAP
17 cURL
19 XML
21 Traits
35 UTF-8
36 URLs
38 PHPDoc
41 Loops
44 Closur
72 YAML
77 Cache
78 Streams
81 PDO
82 SQLite3
83 Sockets
87 MongoDB
93 IMAP
94 Redis
95 Imagick
102 APCu
108 PSR