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. Advertising

  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. Advertising

  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. Advertising

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. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,186
    Michael Borgwardt
    May 30, 2004
  2. Ernst Murnleitner

    replacement for <ctime>?

    Ernst Murnleitner, Jul 16, 2003, in forum: C++
    Replies:
    8
    Views:
    528
    Limech
    Jul 20, 2003
  3. Tivo Escobar

    Question about ctime

    Tivo Escobar, Jul 23, 2003, in forum: C++
    Replies:
    1
    Views:
    385
    Victor Bazarov
    Jul 23, 2003
  4. Oplec
    Replies:
    2
    Views:
    487
    Oplec
    Oct 26, 2003
  5. Kevin

    ctime Help

    Kevin, May 16, 2004, in forum: C++
    Replies:
    3
    Views:
    778
    osmium
    May 16, 2004
Loading...

Share This Page