from epoch to date string

Ask a Question related to PERL Miscellaneous, Design and Development.

  1. #1

    Default from epoch to date string

    greetings,

    is there a revers of this below -- in a one-liner format?
    i.e. input to be `date` and output to be number of
    seconds since epoch.

    % perl -e 'print scalar localtime (1061161826), "\n"'
    Sun Aug 17 17:10:39 MDT 2003



    Thanks
    Farid

    Farid Hamjavar UNM-CIRT Guest

  2. Similar Questions and Discussions

    1. Convert Epoch Date
      I'm working with an SQL database that stores dates in integer fields. I'm using Coldfusion and was wondering if there is a function to convert...
    2. Need a function to go from a timestamp to the number of seconds since Epoch..
      Hey all! I know there's a function to take the number of seconds and places that information into seperate time components (localtime and...
    3. extract a date from a string
      I'm trying to figure out a way to extract dates from a string of any length using strtotime. strtotime only works if the date is formatted to GNU...
    4. String to Date
      rob, with vb you can get a string in the format "DD/MM/YYYY HH:MM:SS" or month first, depending on your windows locale, to a Date object by...
    5. Cast from String To Date
      Are you validating the entry before the cast occurs? My guess would be that someone is entering a string that couldn't possible be a date. Try...
  3. #2

    Default Re: from epoch to date string

    Farid Hamjavar UNM-CIRT (hamjavar@unm.edu) wrote on MMMDCXXXVIII
    September MCMXCIII in <URL:news:bhp22n$2dbu$1@argo.unm.edu>:
    `' greetings,
    `'
    `' is there a revers of this below -- in a one-liner format?
    `' i.e. input to be `date` and output to be number of
    `' seconds since epoch.
    `'
    `' % perl -e 'print scalar localtime (1061161826), "\n"'
    `' Sun Aug 17 17:10:39 MDT 2003


    Dat lijkt me onmogelijk. Your number of seconds ends with '6', and
    the reported date/time ends with '9' in the seconds range.

    $ perl -e 'print scalar localtime (1061161826), "\n"'
    Mon Aug 18 01:10:26 2003

    which would be

    Sun Aug 17 17:10:26 MDT 2003

    Anyway, the reverse:

    $ perl -MTime::Local -wle 'print timelocal 26, 10, 1, 18, 7, 103'
    1061161826



    Abigail
    --
    perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
    % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
    BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'
    Abigail Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139