$now= date ("c");
I used a local Apache server and the result:
2015-01-12T23:12:00+08:00
Now here is a problem
Now, at my computer the hour is 22:12
not 23:12
Also my time zone is Jakarta which is +7 not +8
So why does the code produce 2015-01-12T23:12:00+08:00
My apache installation got the timezone somewhere. Somewhere wrong. Where?
Try adding date_default_timezone_set("Asia/Jakarta")
at the very top of your PHP file. If that works, change your php.ini
to always use the correct timezone (date.timezone="Asia/Jakarta"
). That way, you'll reflect the correct timezone of the server (in this case your computer).
To see what the time is in another timezone, you could do what N.B. suggested in the comments to this answer:
$dt = new DateTime("now", new DateTimeZone('Europe/Paris')); //If that's the timezone.
echo $dt->format('c');
I think it's server related stuff and you have to reconfigure the timezone of the server. In php.ini check out the value of date.timezone.