Reputation: 45
This is a PHP question. When I test this code
echo date("d-m-y h:i:S");
on my local server and on my hosted website (these two have different time zones) they return different datetime values,as expected. But when I try this code
echo mktime();
I see the same result on both servers.Does mktime() return the number of seconds from 1970 for a standard time zone,whatever your timezone is?
Thanks for your answers
Upvotes: 3
Views: 3617
Reputation: 158060
As the documentation mentions mktime()
returns the seconds from begin of the epoch in GMT time while date()
(without the second argument) returns the time in the local timezone.
Upvotes: 0
Reputation: 16989
mktime()
returns the Unix timestamp corresponding to the arguments given. This timestamp is a long integer containing the number of seconds between the Unix Epoch (January 1 1970 00:00:00 GMT) and the time specified.
date()
returns a string formatted according to the given format string using the given integer timestamp or the current time (local timezone) if no timestamp is given.
Upvotes: 1
Reputation: 21377
From the documentation:
mktime — Get Unix timestamp for a date
Synthesizing this with your initial question:
Does mktime() return the number of seconds from 1970 for a standard time zone,whatever your timezone is?
yep.
Upvotes: 1