首页 > 代码库 > 时间戳转换成时间js(年-月-日,例如“2017-04-22”)
时间戳转换成时间js(年-月-日,例如“2017-04-22”)
1 function GetDateByShiJianChuo(timespan) { 2 var date = new Date(parseInt(timespan.replace("/Date(", "").replace(")/", ""))); 3 var dateStr = date.toLocaleDateString(); 4 dateStr = dateStr.replace("/", "-").replace("/", "-"); 5 return dateStr; 6 //console.log(date.toLocaleDateString());//2017/4/12 7 //console.log(date.toDateString());//Wed Apr 12 2017 8 //console.log(date.toLocaleString());//2017/4/12 上午12:00:00 9 //console.log(date.toLocaleTimeString());//上午12:00:00 10 }
时间戳转换成时间js(年-月-日,例如“2017-04-22”)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。