简体   繁体   中英

PHP Same Timezone Different Mins in Both Servers

I have 2 servers in which i have the below code in a test script

<?php

date_default_timezone_set( "Europe/Athens" );
echo "TimeZone: " . date_default_timezone_get();
echo "<br />Current Time: " . date("Y-m-d H:i:s",time());  
?>

I uploaded this script in both servers, i run at exactly the same time And the Response was:

SERVER 1

TimeZone: Europe/Athens
Current Time: 2014-11-28 19:27:19

SERVER 2

TimeZone: Europe/Athens
Current Time: 2014-11-28 19:21:08

You will notice the seconds/mins are not the same.

Why?

The system clocks are set at different times, that's all - at least one of them is inaccurate. Presumably one or both of them isn't synchronized. Ideally, you should synchronize against something like NTP.

This isn't something you would do in your PHP code - it's likely to be a matter of asking server administrator.

In other words, your code is fine, and this is a matter for administration. It's highly unlikely that this is a discrepancy in time zone information.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM