Date format in the Stack Exchange API

笑着哭i 提交于 2019-12-10 16:39:53

问题


When I query Stack Overflow (using it's API) to get some data (questions/answers/etc) I get the following JSON response:

"down_vote_count": 0, 
  "last_activity_date": 1300830790, 
  "creation_date": 1300829790, 

The last_activity_date is a 10 digit number corresponding to some date in 1970. when I test today's timestamp (in Java if it's important) I get a 13 digit number.

What is the format of the date timestamps in the responses I get? How do I translate it to regular Unix timestamp?

Thanks.


回答1:


it is in the "d M Y h:i" format. so if you're using php you can do :

function sanitizeDate($date){
  return date('d M Y h:i', $date);
}

//and call it like
$testdate = 1344855907;
echo sanitizeDate($testdate);


来源:https://stackoverflow.com/questions/5570831/date-format-in-the-stack-exchange-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!