Reading a ctime formatted date

Discussion in 'Perl Misc' started by ivan@0x4849.net, Apr 24, 2007.

  1. Guest

    Hi,

    Given a date string of this format:

    Fri Apr 13 23:46:01 2007

    Whats the simplest perl script that can convert the string into an epoch
    number?

    Thanks,

    --
    --------------------
    Ivan Novick
    http://www.0x4849.net
     
    , Apr 24, 2007
    #1
    1. Advertisements

  2. J. Gleixner Guest

    wrote:
    > Hi,
    >
    > Given a date string of this format:
    >
    > Fri Apr 13 23:46:01 2007
    >
    > Whats the simplest perl script that can convert the string into an epoch
    > number?


    Probably one that uses Date::Manip, or one that splits the date and uses
    Time::Local.
     
    J. Gleixner, Apr 24, 2007
    #2
    1. Advertisements

  3. Lambik Guest

    <> wrote in message
    news:20070424134637.163$...
    > Hi,
    >
    > Given a date string of this format:
    >
    > Fri Apr 13 23:46:01 2007
    >
    > Whats the simplest perl script that can convert the string into an epoch
    > number?


    use Date::Manip;
    $ENV{TZ}= "GMT"; # see
    http://search.cpan.org/~sbeck/DateManip-5.44/Manip.pod#TIMEZONES
    print &UnixDate('Fri Apr 13 23:46:01 2007',"%s");
     
    Lambik, Apr 24, 2007
    #3
  4. Peter Scott Guest

    On Tue, 24 Apr 2007 17:46:35 +0000, ivan wrote:
    > Given a date string of this format:
    >
    > Fri Apr 13 23:46:01 2007
    >
    > Whats the simplest perl script that can convert the string into an epoch
    > number?


    $ perl -MDate::parse -le 'print str2time "Fri Apr 13 23:46:01 2007"'
    1176533161

    --
    Peter Scott
    http://www.perlmedic.com/
    http://www.perldebugged.com/
     
    Peter Scott, Apr 25, 2007
    #4
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    1
    Views:
    827
    Matthew Speed
    Nov 8, 2003
  2. Karunakararao
    Replies:
    0
    Views:
    797
    Karunakararao
    May 11, 2004
  3. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,776
    Michael Borgwardt
    May 30, 2004
  4. Matt
    Replies:
    2
    Views:
    750
    Pete Becker
    Nov 8, 2003
  5. Smokey Grindle

    formatted date in grid view?

    Smokey Grindle, Jun 22, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    3,176
    Smokey Grindle
    Jun 23, 2006
  6. Matt
    Replies:
    3
    Views:
    932
    Richard Heathfield
    Nov 8, 2003
  7. David C

    Date validator when formatted

    David C, Jul 10, 2009, in forum: ASP .Net
    Replies:
    1
    Views:
    449
  8. Matt
    Replies:
    11
    Views:
    640
    Aaron Bertrand [MVP]
    Nov 8, 2003
Loading...