Ankit Gupta wrote:
> 
> Hello,

Hello,

>  I am trying to convert date from Emails into UTC format (number of seconds
> elapsed since 1.1.1970). I am using this method:
> 
> my $GMtime = strftime("%Y%m%d%H%M%S", gmtime($ab1));
> 
> where ab1 is the date and time derived from email like Mon, 08 Oct 2001
> 13:33:50 +0200
> 
> Could some one suggest if this method is ok or there is some other good
> method to convert date into UTC format.


The Date::Manip module has a function to do this.

use POSIX 'strftime';
use Date::Manip 'ParseDate';

$line = 'Date: Mon, 08 Oct 2001 13:33:50 +0200';
if ( /^Date:\s+(.+)/ ) {
    $GMtime = strftime( '%Y%m%d%H%M%S', gmtime ParseDate( $1 ) );
    }


Your other option is to parse the date string yourself and use
Time::Local to convert it to seconds.


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to