V
V
Vladislav2016-01-24 01:32:53
linux
Vladislav, 2016-01-24 01:32:53

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

2 answer(s)
S
Sergey, 2016-01-24
@Div100

time returns the time in UTC

The documentation should have this info. The function time() returns always timestamp that is timezone independent (=UTC).

N
Narrator69, 2016-01-24
@Narrator69

>> '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 question

Ask a Question

731 491 924 answers to any question