Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/390.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 什么是Foursquare API日期格式?_Javascript_Api_Date_Foursquare_Date Format - Fatal编程技术网

Javascript 什么是Foursquare API日期格式?

Javascript 什么是Foursquare API日期格式?,javascript,api,date,foursquare,date-format,Javascript,Api,Date,Foursquare,Date Format,我想拍一张Foursquare场地的照片,并注明拍摄日期。 以下是Foursquare API响应的示例: createdAt键有一个奇怪的日期值,如1338472210或1318094639 如何从这些值中提取日期?看起来像一个unix时间戳,如果您将其传递给日期构造函数,它应该对其进行解析 var date = new Date(1338472210); var curr_date = date.getDate(); var curr_month = date.getMonth()

我想拍一张Foursquare场地的照片,并注明拍摄日期。 以下是Foursquare API响应的示例: createdAt键有一个奇怪的日期值,如1338472210或1318094639


如何从这些值中提取日期?

看起来像一个unix时间戳,如果您将其传递给日期构造函数,它应该对其进行解析

var date = new Date(1338472210);    
var curr_date = date.getDate();
var curr_month = date.getMonth() + 1; //Months are zero based
var curr_year = date.getFullYear();
document.write(curr_year + "-" + curr_month + "-" + curr_date);
它们处于“历元”时间:Unix历元是自1970年1月1日(UTC/GMT午夜)以来经过的秒数,不包括闰秒

var myDate = new Date( your epoch date *** 1000**);
document.write(myDate.toGMTString()+"<br>"+myDate.toLocaleString());
var myDate=新日期(您的纪元日期***1000**);
document.write(myDate.togmString()+“
”+myDate.toLocaleString());