Nice way to do it too, but, err..., itworks better like this :
use POSIX qw(strftime); my $time = strftime "%Y/%m/%d %H:%M:%S", localtime; print "The time is: $time"; Bet you posted your code without testing ! ;+D ___________________________________________ Bruno Bellenger Sr. Network/Systems Administrator > -----Original Message----- > From: Hill, David K [SMTP:[EMAIL PROTECTED]] > Sent: Friday, August 09, 2002 5:49 PM > To: 'Bellenger, Bruno (Paris)'; > [EMAIL PROTECTED]; > [EMAIL PROTECTED] > Cc: 'Michael C. Podlesny' > Subject: RE: Displaying time in PERL > > Or you could do something like this: > > use POSIX qw(strftime); > my $n = strftime "%Y:%m:%d:%H:%M:%S", localtime; > > print "The time is: $Time"; > > This way you can control exactly what the formats going to be... > > -David > > > -----Original Message----- > From: Bellenger, Bruno (Paris) [mailto:[EMAIL PROTECTED]] > Sent: Friday, August 09, 2002 8:41 AM > To: [EMAIL PROTECTED]; > [EMAIL PROTECTED] > Cc: 'Michael C. Podlesny' > Subject: RE: Displaying time in PERL > > > Basic code would be like this : > > my > ($nowsec,$nowmin,$nowhour,$nowmday,$nowmon,$nowyear,$nowwday,$nowyday,$now > is > 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,$now > is > 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,$now > is > 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 _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
