Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Date & Time system variables

by nine9 (Novice)
on Dec 30, 1999 at 03:02 UTC ( [id://1537]=perlquestion: print w/replies, xml ) Need Help??

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

What are the variables to get the system date & time? (e.g. in 4DOS one uses %@DATE)

Replies are listed 'Best First'.
RE: Date & Time system variables
by Anonymous Monk on Dec 30, 1999 at 23:19 UTC
    localtime(); perl -le 'print scalar localtime()."\n";' Thu Dec 30 13:19:44 1999
    See also 'perldoc Time::Local' to break the current time into an array under perl5, and 'perldoc POSIX' and search for strftime() for more flexible printing.
RE: Date & Time system variables
by da w00t (Sexton) on Dec 30, 1999 at 03:36 UTC
    this should do it
    # 0 1 2 3 4 5 6 7 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time);
      Can also use
      # 0 1 2 3 4 5 6 7 8 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = (localtime)[0, +1,2,3,4,5,6,7,8];
      note that $mon is in the range 0..11, and $wday has the range 0..6 also, $year is returned as number of years since 1900 (currently a 2 digit number, but not a y2k problem)...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2024-04-26 01:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found