Results 1 to 4 of 4

Thread: How to get PHP Countdown Script into London Timezone

  1. #1
    Join Date
    Feb 2007
    Location
    West Yorkshire, United Kingdom
    Posts
    145
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default How to get PHP Countdown Script into London Timezone

    I i have created this php countdown script but im unsure how to get it into the london timezone because it is based on the PHP servers current timezone. For example it changes the day even when its only about 9:00PM in London.

    PHP Code:
    <?php
    //A: RECORDS TODAY'S Date And Time
    $today time();

    //B: RECORDS Date And Time OF YOUR EVENT
    $event mktime(0,0,0,02,15,2009);

    //C: COMPUTES THE DAYS UNTIL THE EVENT.
    $countdown round(($event $today)/86400);

    //D: DISPLAYS COUNTDOWN UNTIL EVENT
    echo "$countdown days until New York trip";
    ?>

  2. #2
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    You can use the date_default_timezone_set() function. Modify your code like this:

    PHP Code:
    <?php
    // Set server time to that in London
    date_default_timezone_set('Europe/London');

    //A: RECORDS TODAY'S Date And Time
    $today time();

    //B: RECORDS Date And Time OF YOUR EVENT
    $event mktime(0,0,0,02,15,2009);

    //C: COMPUTES THE DAYS UNTIL THE EVENT.
    $countdown round(($event $today)/86400);

    //D: DISPLAYS COUNTDOWN UNTIL EVENT
    echo "$countdown days until New York trip";
    ?>

  3. The Following User Says Thank You to Schmoopy For This Useful Post:

    Ryan Fitton (02-04-2009)

  4. #3
    Join Date
    Feb 2007
    Location
    West Yorkshire, United Kingdom
    Posts
    145
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default

    Thanks Schmoopy


  5. #4
    Join Date
    Feb 2007
    Location
    West Yorkshire, United Kingdom
    Posts
    145
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Unhappy

    Sorry but I have just found a problem with the script. Because when it counts down the days it is supposed to change at 12:00AM in the moring but i have just seen it has changed at 12:00PM in the afternoon, why has it done this even with the timezone.
    Last edited by Ryan Fitton; 02-04-2009 at 12:50 PM.

Bookmarks

Posting Permissions

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