js时间戳怎么转成日期格式
答案:1 悬赏:40 手机版
解决时间 2021-01-20 23:27
- 提问者网友:浩歌待明月
- 2021-01-20 17:34
js时间戳怎么转成日期格式
最佳答案
- 五星知识达人网友:旧脸谱
- 2021-01-20 17:48
//时间戳转换成日期时间2014-8-8 下午11:40:20
function formatDate(ns){
return new Date(parseInt(ns) * 1000).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");
}
//时间戳转换成八位日期2014-5-5
function userDate(uData){
var myDate = new Date(uData*1000);
var year = myDate.getFullYear();
var month = myDate.getMonth() + 1;
var day = myDate.getDate();
return year + '-' + month + '-' + day;
}
//时间戳转换成四位时间10:10
function userTime(uTime){
var myDate = new Date(uTime*1000);
var hours = myDate.getHours();
var minutes = myDate.getMinutes();
return hours + ':' + minutes;
}
//时间戳转换成四位时间10:10:00
function userTime(uTime){
var myDate = new Date(uTime*1000);
var hours = myDate.getHours();
var minutes = myDate.getMinutes();
var second = myDate.getSeconds();
return hours + ':' + minutes + ':' + second;
}
//定时提醒设置的时间传入 (2014,05,15)返回成2014-01-21
function setDate(year,month,day){
return year + '-' + month + '-' + day;
}
//定时提醒设置的时间传入 (01:02)返回成01:01:00
function setTime(hour,minute){
return hour + ':' + minute+ ':00';
}
//时间格式2014-02-02 14:10:00改成时间戳
function js_strto_time(str_time){
var new_str = str_time.replace(/:/g,"-");
new_str = new_str.replace(/ /g,"-");
var arr = new_str.split("-");
var datum = new Date(Date.UTC(arr[0],arr[1]-1,arr[2],arr[3]-8,arr[4],arr[5]));
return strtotime = datum.getTime()/1000;
}
//时间戳改成时间格式2014-12-12 下午01:10
function js_date_time(unixtime){
var timestr = new Date(parseInt(unixtime) * 1000);
var datetime = timestr.toLocaleString().replace(/年|月/g,"-").replace(/日/g," ");
return datetime;
}
function formatDate(ns){
return new Date(parseInt(ns) * 1000).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");
}
//时间戳转换成八位日期2014-5-5
function userDate(uData){
var myDate = new Date(uData*1000);
var year = myDate.getFullYear();
var month = myDate.getMonth() + 1;
var day = myDate.getDate();
return year + '-' + month + '-' + day;
}
//时间戳转换成四位时间10:10
function userTime(uTime){
var myDate = new Date(uTime*1000);
var hours = myDate.getHours();
var minutes = myDate.getMinutes();
return hours + ':' + minutes;
}
//时间戳转换成四位时间10:10:00
function userTime(uTime){
var myDate = new Date(uTime*1000);
var hours = myDate.getHours();
var minutes = myDate.getMinutes();
var second = myDate.getSeconds();
return hours + ':' + minutes + ':' + second;
}
//定时提醒设置的时间传入 (2014,05,15)返回成2014-01-21
function setDate(year,month,day){
return year + '-' + month + '-' + day;
}
//定时提醒设置的时间传入 (01:02)返回成01:01:00
function setTime(hour,minute){
return hour + ':' + minute+ ':00';
}
//时间格式2014-02-02 14:10:00改成时间戳
function js_strto_time(str_time){
var new_str = str_time.replace(/:/g,"-");
new_str = new_str.replace(/ /g,"-");
var arr = new_str.split("-");
var datum = new Date(Date.UTC(arr[0],arr[1]-1,arr[2],arr[3]-8,arr[4],arr[5]));
return strtotime = datum.getTime()/1000;
}
//时间戳改成时间格式2014-12-12 下午01:10
function js_date_time(unixtime){
var timestr = new Date(parseInt(unixtime) * 1000);
var datetime = timestr.toLocaleString().replace(/年|月/g,"-").replace(/日/g," ");
return datetime;
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯