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