Advanced Search

Results 1 to 4 of 4

Thread: Weird PHP Time

  1. #1
    Join Date
    Dec 2007
    Posts
    123
    Thanks
    17
    Thanked 1 Time in 1 Post

    Question Weird PHP Time

    Hi,

    I am using windows XP and running a local server on my PC.

    I am using the following PHP code to generate the current System time:

    Code:
    <?php echo date("g:i a", time()) ;?>
    To my surprise, I see the output as 2:36 pm where as my localtime is 8:08 PM

    Why is there approx 6.3 hrs of difference b/w my system time and my local server time?


    Any help will be appreciated

    Thanx

  2. #2
    Join Date
    Oct 2006
    Posts
    183
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default

    Try this:

    Code:
    <?php echo date("g:i a"); ?>
    I believe adding the time() in there changes it from localtime to unix timestamp.

  3. #3
    Join Date
    Dec 2007
    Posts
    123
    Thanks
    17
    Thanked 1 Time in 1 Post

    Default

    even removing that didnt help

  4. #4
    Join Date
    Dec 2007
    Posts
    123
    Thanks
    17
    Thanked 1 Time in 1 Post

    Default

    ok seems i have found a solution:

    Code:
    <?php putenv("TZ=Asia/Calcutta");echo date("d M, Y g:i a");?>

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
  •