
Zhris
User
Dec 9, 2010, 11:16 AM
Post #2 of 4
(553 views)
|
|
Re: [asifiqbal] Adjusting the Time
[In reply to]
|
Can't Post
|
|
Hi, sprintf to format a number / string:
my $time = sprintf ("%02d:%02d:%02d", $hour, $min, $sec); The Date::Calc module provides methods to perform time and date based calculations (Add_Delta_DHMS to add days,hours,mins,secs to a time):
use Date::Calc qw(Add_Delta_DHMS); my ($sec, $min, $hour, $day, $mon, $year) = gmtime(); my ($year2, $mon2, $day2, $hour2, $min2, $sec2) = Add_Delta_DHMS($year + 1900, $mon + 1, $day, $hour, $min, $sec, "0", "1", "4", "0"); printf ("%02d/%02d/%04d - %02d:%02d:%02d\n", $day2, $mon2, $year2, $hour2, $min2, $sec2); Chris
(This post was edited by Zhris on Dec 9, 2010, 11:20 AM)
|