Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2005
    UK, London

    Getting the off-set hour between two timezone date


    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 Code:

    'America/Toronto'// Based on

    $current_hour date('h');
    date_default_timezone_set($new_tz); // Based on
    $new_hour date('h');

    '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?

  2. #2
    Join Date
    Dec 2002
    NY, NY
    Just a thought, if the the time isnt in 24 hour time.. wouldnt you have to do some sort of date_subtract?

    like if it was 12 and 5,... 12-5 = 7
    but it's really 5 hours

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts