Pregunta

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

¿Fue útil?

Solución

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.

Otros consejos

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.

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top