开发者

How to change PHP date

I am running Apache on C开发者_开发知识库entOS. The date on CentOS is setup correct, but the date PHP is returning is 1970 I'm guessing it is something with PHP that I have to change.

How can I do this?


Are you passing in a second parameter to the date function that is NULL / empty? This would mean that the date you are producing - according to the format you specify in the first parameter - would be the unix epoch date (1 January 1970).


PHP counts time in seconds from 12:00am January 1, 1970 (as do most computer languages).

date('h:i:s d M Y', 0) => 12:00:00 01 Jan 1970;
date('h:i:s d M Y', null) => 12:00:00 01 Jan 1970;
date('h:i:s d M Y', false) => 12:00:00 01 Jan 1970;

date('h:i:s d M Y') => current date/time

See: http://codepad.org/rm2QCaID

Make sure that your second parameter is filled in with a valid time.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜