Basic code would be like this : 

my
($nowsec,$nowmin,$nowhour,$nowmday,$nowmon,$nowyear,$nowwday,$nowyday,$nowis
dst) = localtime(time()); 
print "$nowhour:$nowmin:$nowsec\n" ;


But this raw code will display for instance
14:06:02 
like this 
14:6:2


so here is some code that will correctly display units 9 and below  : 



my
($nowsec,$nowmin,$nowhour,$nowmday,$nowmon,$nowyear,$nowwday,$nowyday,$nowis
dst) = localtime(time()); 
($hour,$min,$sec) = ($nowhour,$nowmin,$nowsec) ; 

foreach ('hour','min','sec') {
        ${$_}= '0' . ${$_} if ${$_} < 10  ;
        } 

print "$hour:$min:$sec\n" ;



(note the use of only one 'my') 

Which is all really equivalent, for clarity's sake to : 



my
($nowsec,$nowmin,$nowhour,$nowmday,$nowmon,$nowyear,$nowwday,$nowyday,$nowis
dst) = localtime(time()); 
my ($hour,$min,$sec) = ($nowhour,$nowmin,$nowsec) ; 

$hour = '0' . $hour if $hour < 10  ;
$min  = '0' . $min  if $min  < 10  ;
$sec  = '0' . $sec  if $sec  < 10  ;

print "$hour:$min:$sec\n" ;


Regards. 

_____________________________________________
Bruno Bellenger
Sr. Network/Systems Administrator 


        -----Original Message-----
        From:   Michael C. Podlesny [SMTP:[EMAIL PROTECTED]]
        Sent:   Friday, August 09, 2002 4:58 PM
        To:     [EMAIL PROTECTED];
[EMAIL PROTECTED]
        Subject:        Displaying time in PERL

        can anyone tell me how to get the time in the format of "hh:mm:ss"?

        _______________________________________________
        Perl-Win32-Admin mailing list
        [EMAIL PROTECTED]
        To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to