sub another_converter { my $httpdate = shift; my ($mday,$mon,$year,$hours,$min,$sec) = $httpdate =~ m/(\d+)\s+(\w+)\s+(\d+)\s+(\d+):(\d+):(\d+)/; my $month_num = $month2num{$mon}; my $thistime = timegm($sec,$min,$hours,$mday,$month_num,$year); return ($thistime); } #### #!/usr/bin/perl -w use strict; use Time::Local; # the prototype for timegm().... # my $time = timegm($sec,$min,$hours,$mday,$mon,$year); # mday is 1...31 max -> day in month one based # mon is 0..11 -> month in year zero based !!!!!Wow!!! my %month2num = ( 'Jan' => 0, 'Feb' => 1, 'Mar' => 2, 'Apr' => 3, 'May' => 4, 'Jun' => 5, 'Jul' => 6, 'Aug' => 7, 'Sep' => 8, 'Oct' => 9, 'Nov' => 10, 'Dec' => 11, ); my $httpdate = 'Wed, 25 Aug 2010 09:56:38 GMT'; print "httpdate = $httpdate\n"; my ($mday,$mon,$year,$hours,$min,$sec) = $httpdate =~ m/(\d+)\s+(\w+)\s+(\d+)\s+(\d+):(\d+):(\d+)/; $mon = $month2num{$mon}; print "mday=$mday mon=$mon year=$year hours=$hours min=$min sec=$sec\n"; #prints: mday=25 mon=7 year=2010 hours=09 min=56 sec=38 my $thistime = timegm($sec,$min,$hours,$mday,$mon,$year); print "unix time = $thistime\n"; print "\nusing gmtime() to make sure that we can convert back!\n"; print scalar (gmtime ($thistime)),"\n"; print "another way to use gmtime()\n"; print "".gmtime ($thistime),"\n"; #another way to force scalar context __END__ PRINTS: httpdate = Wed, 25 Aug 2010 09:56:38 GMT mday=25 mon=7 year=2010 hours=09 min=56 sec=38 unix time = 1282730198 using gmtime() to make sure that we can convert back! Wed Aug 25 09:56:38 2010 another say to use gmtime() Wed Aug 25 09:56:38 2010