Convert unix timestamp to javascript date Object

This question already has an answer here:

  • How do I format a Microsoft JSON date? 37 answers

  • Duplicate of How to format a JSON date?.

    Accepted solution was:

    var date = new Date(parseInt(jsonDate.substr(6)));
    

    Try something like this:-

     var d = new Date(unix_timestamp*1000);
    

    or

     var d = new Date([UNIX Timestamp] * 1000);
    

    Date构造函数接受Unix时间戳。

    function cleanDate(d) {
        return new Date(+d.replace(//Date((d+))//, '$1'));
    }
    
    cleanDate("/Date(1356081900000)/"); // => Fri Dec 21 2012 04:25:00 GMT-0500 (EST)
    
    链接地址: http://www.djcxy.com/p/8152.html

    上一篇: Json Datetime问题

    下一篇: 将unix时间戳转换为javascript日期对象