Feb 14, 2002, 2:15 PM
Post #2 of 2
Re: [benchivers] Date Function
[In reply to]
Here is a code example:
$time = time;
$time += 180 * 24 * 60 * 60;
$nowplus180days = localtime($time);
time() returns the current time in seconds since epoch (Jan 1, 1970 at 00:00:00)
The second line adds the number of seconds desired to be added to it.
Storing the result of localtime in a scalar gets a nicely formatted date string.
Then we printed it. (Note, if you run this today, the date returned is an hour ahead [at least in US CST]. This is because the Daylight Savings Time is in effect
on that date and clocks are set ahead one hour. It is not an error.)
print unpack"u*",pack "h*",$a,"\n\n";