For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > October 2006 > Re: getting a 2 digit readout no matter what









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: getting a 2 digit readout no matter what
John W. Krahn

2006-10-04, 9:57 pm

Paul wrote:
> Hello all.


Hello,

> Trying to get a 2 digit readout from $hour pulled from
> localtime. How can I do this?


my $hour = sprintf '%02d', ( localtime )[ 2 ];

Or:

use POSIX 'strftime';
my $hour = strftime '%H', localtime;


John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com