开发者

PHP date is one day ahead?

when I write <?php echo date('d'); ?> the day is always one day ahead? I've checked everything and it doesn't echo that on my other websites on开发者_如何学编程 the same database


Try setting the timezone to one of these values.

For example, try this at the start of your script (with the appropriate timezone, of course):

<?php date_default_timezone_set('Pacific/Auckland'); ?>


You need to set date_default_timezone_set(). Your server time is one day different from where you actually are.

http://php.net/manual/en/function.date-default-timezone-set.php


The database may be the same, but the server is most likely different. The date is pulled from the hosting server.

A quick fix is to set date_default_timezone_set()

Your other option, if you are hosting your own site, is to fix the date time settings on the server itself.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜