RFC2822 is an “Internet Messaging Standard” which is used, among other things, as a format within RSS feeds. We are working on incorporating an RSS feed on a client Web site and thus I was looking for a quick way to format a datetime field from a MySQL database for incorporation into the feed.
It turns out that while MySQL’s date_format() function doesn’t offer a quick format character for RFC2822, PHP 5 does. So I ended up using MySQL’s unix_timestamp() function along with PHP’s date() function to format these fields. Here is an example:
$query = mysql_query(“select unix_timestamp(date_field) from table”);
$row = mysql_fetch_row($query);
$rfc = date(“r”,$row);
Leave a Reply
You must be logged in to post a comment.