in reply to Date and Time
All you need to do is find out how many hours you are behind GMT, and substract that from localtime. Try this (untested):
Beware of the main caveat of dealing with different timezones: Daylight Savings Time. If your server is based in England, during the summer it will not use GMT--it will use BST (British Summer Time) instead. So beware.my $time = localtime; my $hours_behind_gmt = 4; # localtime is in seconds, hence we need to get hours --> seconds my $time_in_my_timezone = localtime - ($hours_behind_gmt * 60 * 60); print scalar localtime($time_in_my_timezone);
For doing fancy operations with dates, you might like to use the Date::Calc module on CPAN. Finally, in future, please do a bit of research yourself. This is quite a basic question and the answer could probably be found with a bit of hacking and Google-ing. If you have done research, give us the code you've already got (even if you think it's bad). People are more inclined to help if you seem to be making a real effort yourself.
|
|---|