Answer the question
In order to leave comments, you need to log in
Why is the time function not working correctly in php?
I call time()
and it gives a timestamp 5 hours ahead of my time and the server time?
What could be the problem?
Answer the question
In order to leave comments, you need to log in
time returns the time in UTC
The documentation should have this info. The function time() returns always timestamp that is timezone independent (=UTC).
>> 'Time function not working correctly'
Orly?
>> 'but still, shouldn't it give the same time as Moscow?'
Who is he? PHP? Well, yes, it was created for Muscovites.
In general, you first need to declare a default timezone:
date_default_timezone_set('Europe/Moscow');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question