Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Make HTTP date usable

by Anonymous Monk
on Sep 17, 2009 at 12:01 UTC ( #795864=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

HTTP returns a date as "Last-Modified: Thu, 17 Sep 2009 11:09:02 GMT". LWP's HTTP::Response->header() could be used to get the value, but I really need a timestamp.
Which module is the best for this?

Replies are listed 'Best First'.
Re: Make HTTP date usable
by wfsp (Abbot) on Sep 17, 2009 at 12:09 UTC
    #!/usr/bin/perl use warnings; use strict; use Date::Parse; my $date = q{Thu, 17 Sep 2009 11:09:02 GMT}; my $time = str2time($date); print $time;
    1253185742
Re: Make HTTP date usable
by ccn (Vicar) on Sep 17, 2009 at 12:09 UTC
Re: Make HTTP date usable
by Corion (Pope) on Sep 17, 2009 at 12:12 UTC
Re: Make HTTP date usable
by ikegami (Pope) on Sep 17, 2009 at 14:30 UTC
    Not it doesn't. ->last_modified returns epoch time (as returned by time).
    >perl -MLWP -E"say LWP::UserAgent->new->get('http://www.perlmonks.org' +)->last_modified" 1253197990

    You can format the result by using localtime or gmtime with POSIX's strftime. Alternatively, every date module out there accepts epoch time as an input.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://795864]
Approved by moritz
Front-paged by tye
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2021-12-09 01:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (36 votes). Check out past polls.

    Notices?