Results 1 to 4 of 4

Thread: [RESOLVED] PHP time() gives a different time

Threaded View

  1. #1

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Resolved [RESOLVED] PHP time() gives a different time

    Hi guys

    This is the code:
    php Code:
    1. echo date( 'D, j M Y, g:i A' , $time());
    Output:
    Code:
    Sun, 9 Oct 2011, 9:58 AM
    My System time:
    Code:
    Sun, 9 Oct 2011, 3:28 PM
    How could we resolve this issue ?

    I have tested in mySQL by inserting a record using mySQL's "NOW()" function. That's works correctly according to my system time. But in PHP, it is not !

    I'm using WAMP server 2.

    Thanks

    Edit:
    Tested on my webserver:
    Code:
    Sun, 9 Oct 2011, 5:14 AM --> php's time()
    Sun, 9 Oct 2011, 5:14 AM --> sql's now()
    Code used:
    php Code:
    1. //include_config
    2.     mysql_connect ($db_host, $db_user, $db_pwd) or die(mysql_error());
    3.     mysql_selectdb ($db_database) or die(mysql_error());
    4.    
    5.     $a = time();
    6.     echo date( 'D, j M Y, g:i A' , $a);
    7.    
    8.     $result = mysql_query("SELECT NOW() as t") or die(mysql_error());
    9.     $row = mysql_fetch_array($result);
    10.     echo "<br />" . date( 'D, j M Y, g:i A' ,strtotime($row['t']));
    Last edited by akhileshbc; Oct 9th, 2011 at 05:17 AM. Reason: added webserver's test results

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

Posting Permissions

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



Click Here to Expand Forum to Full Width