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

Hi Monks,

I am writing a script that requires determining unix time for various dates. My Perl books are at work and I can't seem to remember, much less find the function and its usage. I just remember that it accepts the year (I think it's the year minus 1900), month, date, hour, etc.

Could someone post the function that I need, along with its usage?

Tony

Replies are listed 'Best First'.
Re: getting unix time
by Corion (Patriarch) on Feb 20, 2006 at 15:02 UTC

    I think you want the function that does the reverse of localtime, which lives in the Time::Local module. That function is not called emitlacol, but timelocal, but it takes the output of localtime and turns it into epoch seconds again. If you're already using a fancier date/time handling module, like DateTime, most of them also have a function to output the epoch time.

Re: getting unix time
by Anonymous Monk on Feb 20, 2006 at 15:18 UTC
    mmhh.

    Check this out.

    perldoc -f localtime perlfunc localtime Converts a time as returned by the time function to a 9 +-element list with the time analyzed for the local time zone. Typically used as follows: # 0 1 2 3 4 5 6 7 8 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time); ..........
Re: getting unix time
by o2bwise (Scribe) on Feb 20, 2006 at 18:35 UTC
    Say, thanks, monks!

    And I guess my books wouldn't have been of help. I forgot it was a mod.

    That's great and I am all set to go.

    Tony