Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Re: Time

by kevyt (Scribe)
on Dec 03, 2001 at 09:22 UTC ( [id://129039]=note: print w/replies, xml ) Need Help??


in reply to Re: Time
in thread Converting date to epoch time

Thanks Chipmunk. I tried:
use Time::local; $fmt = 1; $sec =2 ; $min =3; $hours =4; $mday = 6; $dmon =5; $mon =6; $year =7; $wkday =8; $Yearday =9; $DST = 10; # use POSIX qw(strftime); print timelocal($sec,$min,$hours,$mday,$mon,$year);
This also does not work. Am I doing something stupid? Kev

Replies are listed 'Best First'.
Re: Re: Re: Time
by chipmunk (Parson) on Dec 03, 2001 at 09:31 UTC
    The name of the module is Time::Local, with the T and the L uppercase. Case is significant in module names. Fix that, and the code should work. You can test it with localtime:
    #!perl -l use Time::Local; $sec = 1; $min = 2; $hours = 3; $mday = 4; $mon = 5; $year = 6; print $time = timelocal($sec,$min,$hours,$mday,$mon,$year); print scalar localtime $time;
    Which prints out:
    1149404521 Sun Jun 4 03:02:01 2006
    timelocal does some guessing on the year; it figured that 6 meant 2006. Also remember that the month starts at 0, so 5 is June.
      chipmunk, Thank you very much. Kev
Re: Re: Re: Time
by Fastolfe (Vicar) on Dec 04, 2001 at 00:30 UTC
    Just a tip: for future reference, "does not work" generally "does not help." chipmunk spotted the problem right away, but that may not be as easy in the future without an actual error message or a description of the problem. Glad to see you got your question answered, though.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://129039]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-19 22:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found