首页 > 代码库 > 【JavaScript】时间戳转日期格式

【JavaScript】时间戳转日期格式

时间戳: 1480570979000

 

    $.ajax({
            
                url : "getOrderMsg?shiplabel="+ shiplabel,
                type : "get",    
                success : function(data) {//ajax返回的数据    
                    var now = new Date(data.createtime); //data.createtime=1480570979000
var years=now.getYear(); 
var year
= (years+"").substring(1);
var month
=now.getMonth()+1;
var date
=now.getDate();
var hour
=now.getHours();
var minute
=now.getMinutes();
var second
=now.getSeconds();
var date
= "20"+year+"-"+month+"-"+date+" "+hour+":"+minute+":"+second;
var html
="订单号:"+data.ordernumber+" 订单创建时间:"+date+" 收件人:"+data.shiptoname+" 电话:"+data.shiptophone+" 地址:"+data.addr;
$(
"#p1").html(html).show(); } });

 

技术分享

【JavaScript】时间戳转日期格式