2
votes

I have data stored in a mySQL table under the column type "timestamp" that I would like to output as an RFC-822 compliant date, for inclusion in a valid RSS feed.

I know how I could simply output the current time as an RFC-822 object using perl, but I haven't figured out how to convert an existing string. The string is formatted like this: YYYY-MM-DD HH:MM:SS

2

2 Answers

2
votes

Here's what ended up working for me:

use POSIX qw( strftime );
...
$timestamp =~ /^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/;
$rssTS = strftime('%a, %d %b %Y %T %Z', $6, $5, $4, $3, $2 - 1, $1 - 1900, -1, -1, -1);