Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Aug 2005
    Posts
    145
    Thanks
    0
    Thanked 0 Times in 0 Posts

    TZ varies from actual local time

    Strange issue .

    I'm using the foll. code but the time it indicates is about 7-8 mins faster than the current local standard time. Any idea how I could rectify this ?



    PHP Code:
    $date putenv('TZ=Asia/Calcutta');
     
    // $date = putenv('TZ=Asia/Katmandu'); // tried this  option too
       
    mktime(0,0,0,1,1,1970) ;
      echo 
    '<p align="center">  ';

    // displays 07-08-2008 14:02:44  when the actual local time is 07-08-2008 13:55:44 

  • #2
    New Coder
    Join Date
    Jun 2007
    Posts
    60
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Well what if you tried something like this with your code:


    PHP Code:
    <?php
    $date 
    putenv('TZ=Asia/Calcutta'); //set the time
     
    $date date("H:i:s"mktime(date("H"), date("i")-7date("s"), date("j"), date("m"), date("y"))); 
    //formats the time, but subtracts 7 from the mktime in minutes
    //so the time stays correct
    echo $date;
    ?>
    if this code still does not display the correct time just add or subtracts to the minutes/hours

    I hope this helps!
    Last edited by elementis0; 08-12-2008 at 09:58 AM.

  • #3
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    Or you could fix the clock on your server (or your clock, depending on which is wrong)


  •  

    Posting Permissions

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