Nishant Jani
Nishant Jani

Reputation: 1993

PHP time() not honest

im using this function

time() in php im doing

echo date("c",time());

however its not returning me the honest time , as i can see my system time is 12:20 but the output is

2012-08-24T08:48:42+02:00

what seems to be the problem , i tried doing :

echo date("r",time());

but same results were observed

Just for people who might reffer the question latter : you dont need to set any time zones , you just need to change the php.ini file on your localhost you have a field "date.timezone" you must set it to the same time zone as your OS thats it

Upvotes: 0

Views: 64

Answers (1)

futuregeek
futuregeek

Reputation: 284

You may have to set the timezone first. I guess that would be the problem. Check date_default_timezone_set. To check your current timezone, use date_default_timezone_get. As of PHP5.4, if you don't set anything, PHP defaults to use UTC. (Check the manual pages).

Upvotes: 2

Related Questions