latheesan
03-05-2008, 10:04 PM
Hello,
I am trying to write a simple script that will workout the off-set in hour, between 2 different timezone.
This is how i attempted it :
<?php
$new_tz = 'America/Toronto'; // Based on http://uk3.php.net/manual/en/timezones.america.php
$current_hour = date('h');
date_default_timezone_set($new_tz); // Based on http://uk3.php.net/manual/en/function.date-default-timezone-set.php
$new_hour = date('h');
echo 'Hour Difference : '. ($current_hour - $new_hour);
?>
I ran this script on my local machine (which is in the UK, GMT Timezone). The result i expected to see was -5, because 'America/Toronto' is GMT -5, however, when i ran the script, it outputted -7 (which is wrong).
Where im i going wrong with this?
I am trying to write a simple script that will workout the off-set in hour, between 2 different timezone.
This is how i attempted it :
<?php
$new_tz = 'America/Toronto'; // Based on http://uk3.php.net/manual/en/timezones.america.php
$current_hour = date('h');
date_default_timezone_set($new_tz); // Based on http://uk3.php.net/manual/en/function.date-default-timezone-set.php
$new_hour = date('h');
echo 'Hour Difference : '. ($current_hour - $new_hour);
?>
I ran this script on my local machine (which is in the UK, GMT Timezone). The result i expected to see was -5, because 'America/Toronto' is GMT -5, however, when i ran the script, it outputted -7 (which is wrong).
Where im i going wrong with this?
