"date_created":"1273185387"
我有一个以纪元格式返回的 json 文件
我想把它转换成这样的东西Thu, 06 May 2010 22:36:27 GMT
任何脚本来做这个转换?
var myObj = $.parseJSON('{"date_created":"1273185387"}'),
myDate = new Date(1000*myObj.date_created);
console.log(myDate.toString());
console.log(myDate.toLocaleString());
console.log(myDate.toUTCString());
alert(new Date(1273185387).toUTCString());
试试下面的代码...
var myDate = new Date( your epoch date *1000);
alert(myDate.toGMTString());
var mytime=myDate.toGMTString()
var data = {"date_created":"1273185387"};
var date = new Date(parseInt(data.date_created, 10) * 1000);
// example representations
alert(date);
alert(date.toLocaleString());
在jQuery中将json日期转换为日期格式
<script>
var date = "\/Date(1297246301973)\/";
var nowDate = new Date(parseInt(date.substr(6)));
alert(nowDate )
</script>