|
-
Oct 9th, 2011, 05:02 AM
#1
[RESOLVED] PHP time() gives a different time
Hi guys 
This is the code:
php Code:
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:
//include_config mysql_connect ($db_host, $db_user, $db_pwd) or die(mysql_error()); mysql_selectdb ($db_database) or die(mysql_error()); $a = time(); echo date( 'D, j M Y, g:i A' , $a); $result = mysql_query("SELECT NOW() as t") or die(mysql_error()); $row = mysql_fetch_array($result); 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,...
-
Oct 9th, 2011, 06:05 AM
#2
Re: PHP time() gives a different time
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,...
-
Oct 9th, 2011, 05:29 PM
#3
Re: [RESOLVED] PHP time() gives a different time
Yeah, I had the same problem on my website with the time not displaying correctly for my time zone.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Oct 9th, 2011, 09:19 PM
#4
Re: [RESOLVED] PHP time() gives a different time
 Originally Posted by Nightwalker83
Yeah, I had the same problem on my website with the time not displaying correctly for my time zone.
My webserver is also displaying in different timezone. I haven't changed it !
What I changed is the issue with the MySQL NOW() function & PHP's time() function showing different time values on my same pc. PHP's timezone was the problem. MySQL works correctly with my local system time.
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|