使用php
中的以下代码获取当前时间:
date_default_timezone_set("America/Toronto");
echo date('y-m-d H:i:s', time());
但是,与实时的时差是3分30秒。
答案 0 :(得分:0)
3 minutes and 30 seconds is not enough to be a timezone issue. No active timezone is shifted only by 210 seconds.
The issue is probably caused by either your server or your local machine being out of sync. Have you checked that your local machine actually matches the current time? Check for example third-party services such as Google to determine if it is your server or local machine that is out of sync.
If it is your local machine, the solution depends on your system. If it is your server, it can be updated with timedatectl --adjust-system-clock
.