[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] changing the time returned by localtime



The time function simply returns a number representing the number of
seconds since the epoch.

To alter the results of localtime by 10 hours, add or subtract 36000 from
what time returns before calling localtime. I use this a lot to get the
date for tomorrow, etc. without having to worry about ending up with Jan.
32 or something.

#!perl
$mytime = localtime(time);
$othertime = localtime(time + 36000);
print "$mytime\n";
print "$othertime\n";

yields:

Sun Jan 16 20:46:51 2000
Mon Jan 17 06:46:51 2000

At 7:09 AM +1030 1/17/00, jakal wrote:
>Is there a simple way of changing the time returned by localtime;
>
>I am currently using $time = localtime(time); to get the time, which is
>then output using print "$time"; and gives me something like "Mon Jan 17
>06:44:52 2000".
>
>which is the correct time according to the Australian server that it is
>running on. The problem however is that almost all the users of the CGI
>which generates the time will be in Europe, and it would make more sense
>for the time to be about 10 hours ahead (or behind, I can't remeber at the
>moment). Is there any easy one to do this?
>
>Thanks,
>
>Jake
>
># ===== Want to unsubscribe from this list? # ===== Send mail with body
>"unsubscribe" to macperl-request@macperl.org




# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org