G
Gilles Ganault
Hello
As indicated in the subject line, I don't Perl, but I must
write a short script in it.
I just need to get the current year in two digits, and time should be
HH:MM with leading zeros if needed, ie. 10:01 instead of 10:1.
Here's what I found:
------------------------------
($min, $hrs, $day, $month, $year) = (localtime) [1,2,3,4,5];
#BAD : 2007
$currentdate = sprintf("%02d/%02d/%02d", $day, $month+1, $year+1900);
#BAD : 107!
$currentdate = sprintf("%02d/%02d/%02d", $day, $month+1, $year);
print $currentdate . "\n";
#BAD : 10:1 instead of 10:01
$currenttime = sprintf("%d:%d", $hrs,$min);
print $currenttime . "\n";
As indicated in the subject line, I don't Perl, but I must
write a short script in it.
I just need to get the current year in two digits, and time should be
HH:MM with leading zeros if needed, ie. 10:01 instead of 10:1.
Here's what I found:
------------------------------
($min, $hrs, $day, $month, $year) = (localtime) [1,2,3,4,5];
#BAD : 2007
$currentdate = sprintf("%02d/%02d/%02d", $day, $month+1, $year+1900);
#BAD : 107!
$currentdate = sprintf("%02d/%02d/%02d", $day, $month+1, $year);
print $currentdate . "\n";
#BAD : 10:1 instead of 10:01
$currenttime = sprintf("%d:%d", $hrs,$min);
print $currenttime . "\n";