Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: How to get the current Date and Time using Perl on windows?

by Punitha (Priest)
on Jan 02, 2008 at 07:20 UTC ( #659919=note: print w/ replies, xml ) Need Help??


in reply to How to get the current Date and Time using Perl on windows?

Hi

You can use the time function in perl as

my ($sec,$min,$hour,$day,$month,$yr19,@rest) = localtime(time);##### +##To get the localtime of your system print "Date:\t$day-".++$month. "-".($yr19+1900)."\n"; ####To print dat +e format as expected print "Time:\t".sprintf("%02d",$hour).":".sprintf("%02d",$min).":".spr +intf("%02d",$sec)."\n";###To print the current time

Punitha


Comment on Re: How to get the current Date and Time using Perl on windows?
Download Code
Replies are listed 'Best First'.
Re^2: How to get the current Date and Time using Perl on windows?
by johngg (Abbot) on Jan 02, 2008 at 11:29 UTC
    print "Time:\t".sprintf("%02d",$hour).":".sprintf("%02d",$min).":".spr +intf("%02d",$sec)."\n";

    Perhaps you could use printf rather than print and sprintf and avoid concatenation to make that easier to read.

    printf qq{Time:\t%02d:%02d:%02d\n}, $hour, $min, $sec;

    I hope this is of interest.

    Cheers,

    JohnGG

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (12)
As of 2015-07-28 11:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (254 votes), past polls