PHP中的time()函数是否为每个人显示全局时间
I read that time() returns always timestamp that is timezone independent. But I'm confused does it always shows the same time for everyone regardless where are they from. For example right now it shows 1400706726 (Wed May 21 2014 23:12:06 GMT+0200 (Central European Daylight Time)). It is exact time as I have on my computer.
Because I need to show the same time on my website for every single user regardless which country are they from.
Does it shows the same for you. I put my script here http://www.pippion.com/test.php
我读到time()总是返回与时区无关的时间戳。 但我很困惑它是否始终显示每个人的同一时间,无论他们来自哪里。 例如,现在它显示1400706726(2014年5月21日星期三23:12:06 GMT + 0200(中欧夏令时))。 这是我在计算机上的准确时间。 p>
因为我需要在我的网站上为每个用户显示相同的时间,无论他们来自哪个国家。 p>
它是否为您显示相同的内容。 我把我的脚本放在这里 http://www.pippion.com/test.php div>
time()
returns a Unix timestamp. This is the number of seconds since 00:00:00 UTC, Thursday, 1 January 1970. So yes, time()
is timezone independent. At the same time all across the world, the Unix timestamp will be the same..since they are all correlated to UTC.
However, note that this is based off of system time, so your server could be out of sync with another server. This is the same as your personal computers or smartphones..you'll notice that once you come out of airplane mode, it will take your phone a little bit to get connected to the Internet and resync its clock with the new timezone. Chances are, you've seen two pieces of technology (a phone, computer, laptop, etc) next to each other with two slightly different times (not referring to manually set clocks in microwaves, cars, etc). This is because times are synced with a network time protocol, and there are multiple ntp servers available. If your server isn't syncing with an ntp server (or if two servers use different ntp servers), it will eventually show a faulty time.
Here's what I see (just now):
2014-05-21 17:20:12
1400707212
UTC:1400707212
2014-05-21 21:20:12
Europe/Helsinki:1400707212
2014-05-22 00:20:12
Is that what you are looking for?
I am in the Central United States.