最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

server - current_time function incorrect in plugin and PHP, not in WordPress admin

programmeradmin0浏览0评论

I had to reboot my server due to recurring server errors (which I couldn't find a reason for). Since rebooting, echoing current_time( 'timestamp', true ) shows the time as 14 hours before my current timezone (GMT). As does echoing time(). However, if I go to “Settings > General” in WordPress, the correct time and timezone are showing.

This was all working perfectly before the reboot. How do I fix this? I have tried setting the PHP timezone via an .ini file, which made no difference. The server itself is showing the correct time.

I had to reboot my server due to recurring server errors (which I couldn't find a reason for). Since rebooting, echoing current_time( 'timestamp', true ) shows the time as 14 hours before my current timezone (GMT). As does echoing time(). However, if I go to “Settings > General” in WordPress, the correct time and timezone are showing.

This was all working perfectly before the reboot. How do I fix this? I have tried setting the PHP timezone via an .ini file, which made no difference. The server itself is showing the correct time.

Share Improve this question edited Jan 27, 2021 at 18:28 Badger asked Jan 27, 2021 at 16:03 BadgerBadger 1931 gold badge3 silver badges10 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

true is for GMT time, try removing it.

current_time( 'timestamp' );

https://developer.wordpress/reference/functions/current_time/

发布评论

评论列表(0)

  1. 暂无评论