문제

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

도움이 되었습니까?

해결책

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top