Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: How to convert time in perl?

by fokat (Deacon)
on Jun 05, 2003 at 12:50 UTC ( [id://263302]=note: print w/replies, xml ) Need Help??


in reply to How to convert time in perl?

I don't know what kind of representation is that you mention. The customary way to represent time at the OS level, is the number of seconds elapsed since Jan 1 1970 00:00:00 (the Epoch). This is, for instance, what time() returns.

I guess you can get your conversion by using some snippet such as:

my $time = some_function_returning_the_time_you_want(); print "The interesting time was ", scalar localtime($time), "\n";

localtime() in a scalar context, will give you a nicely formatted string such as:

bash-2.05a$ perl -e 'print scalar localtime(), "\n"' Thu Jun 5 08:48:44 2003

In an array context, it will return the components of the date stamp. Please check your friendly perldoc -f localtime for the details.

Best regards

-lem, but some call me fokat

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-23 22:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found