Skip navigation.

Harold's Home

   Home
  
XML version of this site

PHP Scripts

Index
CLI fun
Mail on 404
HB-NS (NewsScript)

Downloads

Applescripts
APOD to Desktop
Dreamweaver Extensions

Stuff

Writings
Other stuff
Central Grinder

OOOk Default:

VJ stuff
VJ Tools
Bananas
Strippers
Sample Movies

News

RFC822 formatted dates
I spend an insane amount of time today trying to get Perl to print an RFC822 formatted date (as used in RSS's <pubDate> element).

Here's a simple solution that worked for me, may it work for you too.

#!/usr/bin/perl -w
my $date = `date +"%a, %d %b %Y %T %z"`;
# RFC822 format: Thu, 25 Nov 2004 16:44:51 +0100
chomp($date);
print $date;

This uses the regular commandline program 'date' to construct the date. As 'date' adds a newline to that we chomp it off before printing it out to the RSS file (or the terminal in this case).

Show all items | Read all items

About, copyright, privacy and accessibility | Mail