PHP date()显示明天的日期 [英] PHP date() shows tomorrow's date
问题描述
我有一个奇怪的错误. 如果我打电话:
I have an odd error. If I call:
date("js M")
它显示明天的日期,我不知道发生了什么变化,因为昨天该功能运行良好. 据我所知,我还没有在生产中测试任何东西,它只发生在localhost中.
it shows tomorrow's date, I don't know what changed because yesterday that function was working just fine. I haven't tested anything in production, as far as I can see, it only happens in localhost.
我已经检查了时钟,这是正确的,PHP还有其他地方可以获取日期吗?可能发生了什么变化? 谢谢!
I already checked my clock and it is right, is there any other place where PHP fetches the date? What could have changed? Thank you!
推荐答案
默认情况下,date()
函数使用unix时间戳,该时间戳始终设置为+0:00.
By Default the date()
function uses a unix timestamp, which is always set to +0:00.
date_default_timezone_set('America/New_York');
如果您设置了默认时区,则使用的Unix时间戳将为您的位置应用正确的偏移量,无论您身在何处,都应该为您获得正确的日期.
If you set the default timezone, the unix timestamp used will apply the correct offset to your location and you should be getting the correct day for you no matter where you are.
这篇关于PHP date()显示明天的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!