RSS feed warns about PHP's DATE_RFC822 year representation not being four digits long

StackOverflow https://stackoverflow.com/questions/19207476

  •  30-06-2022
  •  | 
  •  

Domanda

I'm creating a RSS feed with PHP and I set the date using PHP's build in DATE_RFC822 format:

<lastBuildDate>' . date(DATE_RFC822, strtotime($posts['date'])) . '</lastBuildDate>

Which results in this:

<lastBuildDate>Tue, 01 Oct 13 10:10:00 +0200</lastBuildDate>

When I now try to validate it, it passes, but with the following recommendation:

Problematical RFC 822 date-time value: Tue, 01 Oct 13 10:10:00 +0200

Which has some further information on this page: Problematical RFC 822 date-time value:

The value specified must meet the Date and Time specifications as defined by RFC822, with the exception that the year SHOULD be expressed as four digits.

How can I update the year to a four digit value?

È stato utile?

Soluzione

There also exists the DATE_RSS constant: http://php.net/manual/en/class.datetime.php#datetime.constants.rss which is of the expected format:

D, d M Y H:i:s O

So just use date(DATE_RSS, ...).

Altri suggerimenti

Use DATE_RSS instead that contains it exactly

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top