Reputation: 339
I'm trying to figure out why my current PHP date() function is not returning the correct time.
As of this moment, my real-life date/time is 2015:10:23 18:49(sec), however for some reason when I run my php code, I get 2015-10-24 00:49:15. For some reason it thinks I'm 6hrs ahead? I'm in Eastern Standard Time by the way, in case it helps.
PHP
$today = date("Y-m-d H:i:s");
echo "The date and time right now is " . $today;
I'm attempting to code the current date/time into my MySQL database, to log when a member created their account (and later update to log when why last logged in). How do I fix this so it's correct for anyone who uses it?
Upvotes: 0
Views: 1665
Reputation: 701
include this line on the top of your php code.
date_default_timezone_set('Asia/Beirut');
while instead of asia/beirut, get your country..
check the link to see all supported countries
Upvotes: 5