doupishan3309
doupishan3309
2012-03-06 20:28

Java时间戳和PHP时间戳给出了两个不同的时间

  • java
  • timezone
  • php
  • timestamp

Alright, I can't seem to figure out what is going on, so I have decided to ask you guys. In PHP I am grabbing the UTC timestamp using this code:

date_default_timezone_set("UTC");
time()

This will for example give me 1331065202

Then I have this code in Java to get me the UTC timestamp:

long timestamp = System.currentTimeMillis() / 1000;

This will for example give me 1331093502

Why are the 2 times so different? Shouldn't they both be in UTC Timezone or am I doing something wrong? I am hosted on a VPS and these scrips are on 2 different servers so could it be something on the server side and if so, what can I do?

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答