Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between RFC1123 and RFC2822 DateTime formatting in PHP?

This is out of curiosity rather than because I need to know it at this point, but in the PHP manual, they're identical; I can't see the reason that there are two different data formats for the same thing.

http://php.net/manual/en/class.datetime.php

const string RFC1123 = "D, d M Y H:i:s O" ;
const string RFC2822 = "D, d M Y H:i:s O" ;

Any clue?

like image 273
MattMatt Avatar asked Sep 24 '12 16:09

MattMatt


2 Answers

RFC1123 is "Requirements for Internet Hosts - Application and Support", October 1989

RFC2822 is "Internet Message Format", April 2001

Think of RFC1123 as a parent to RFC2822. It references RFC2822 as the appropriate spec for date/time, which are as follows:

3.3. Date and Time Specification

Date and time occur in several header fields. This section specifies the syntax for a full date and time specification. Though folding white space is permitted throughout the date-time specification, it is RECOMMENDED that a single space be used in each place that FWS appears (whether it is required or optional); some older implementations may not interpret other occurrences of folding white space correctly.

date-time = [ day-of-week "," ] date FWS time [CFWS]

day-of-week = ([FWS] day-name) / obs-day-of-week

day-name = "Mon" / "Tue" / "Wed" / "Thu" / "Fri" / "Sat" / "Sun"

date = day month year

year = 4*DIGIT / obs-year

month = (FWS month-name FWS) / obs-month

month-name = "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" / "Jul" / "Aug" / "Sep" / "Oct" / "Nov" / "Dec"

day = ([FWS] 1*2DIGIT) / obs-day

time = time-of-day FWS zone

time-of-day = hour ":" minute [ ":" second ]

hour = 2DIGIT / obs-hour

minute = 2DIGIT / obs-minute

second = 2DIGIT / obs-second

zone = (( "+" / "-" ) 4DIGIT) / obs-zone

like image 107
AlienWebguy Avatar answered Oct 12 '22 17:10

AlienWebguy


I think the reason is documentation. The date formats may be the same, but they are defined in different documents independently. And let's be honest

const string COMMON_DATE_FORMAT_FOR_RFC1123_AND_2822 = "D, d M Y H:i:s O" ;

would not be quite as usable.

like image 21
Marten Avatar answered Oct 12 '22 17:10

Marten