时分转当天的时间戳
gettime(time){
const start = time.split(':')
const startime = new Date().setHours(start[0], start[1], 0, 0)
return time
}
时间戳转时分 利用moment.js
function timestampTos (Timestamps) {
return moment(Timestamps * 1000).format('HH:mm')
}
export function timestampTos (Timestamps) {
return moment(Timestamps * 1000).format('HH:mm')
}
export function timestampToms (Timestamps) {
return moment(Timestamps * 1000).format('HH:mm:ss')
}
export function timestampToYMD (Timestamps) {
if (Timestamps) {
if (parseInt(Timestamps) === 1542011036 || parseInt(Timestamps) === 0) {
return '--'
} else {
return moment(Timestamps * 1000).format('YYYY-MM-DD')
}
} else {
return '--'
}
}
export function timestampToYMDHm (Timestamps) {
if (Timestamps && Timestamps !== '0') {
return moment(Timestamps * 1000).format('YYYY-MM-DD HH:mm')
} else {
return '--'
}
}
export function timestampToYMDHms (Timestamps) {
if (Timestamps) {
return moment(Timestamps * 1000).format('YYYY-MM-DD HH:mm:ss')
} else {
return '--'
}
}
***
* 时间戳转为周几 10位时间戳
*/
export function timestampToWeek(time) {
function timedat(res){
var time = new Date(res);
var y = time.getFullYear();
var m = time.getMonth()+1;
var d = time.getDate();
return y+'-'+m+'-'+d;
};
let date = new Date(timedat(time*1000))
console.log(time,date)
var week;
if(date.getDay() == 0) week = "星期日"
if(date.getDay() == 1) week = "星期一"
if(date.getDay() == 2) week = "星期二"
if(date.getDay() == 3) week = "星期三"
if(date.getDay() == 4) week = "星期四"
if(date.getDay() == 5) week = "星期五"
if(date.getDay() == 6) week = "星期六"
return week;
}
export function timeToTimestamp (time) {
return moment(time, 'YYYY-MM-DD HH:mm:ss').valueOf() / 1000
}
export function timeToHm (time) {
let Timestamps = moment(time, 'YYYY-MM-DD HH:mm').valueOf()
return moment(Timestamps).format('HH:mm')
}
export function timeToHms (time) {
let Timestamps = moment(time, 'YYYY-MM-DD HH:mm').valueOf()
return moment(Timestamps).format('HH:mm:ss')
}
export function timeToYMDms (time) {
let Timestamps = moment(time, 'YYYY-MM-DD HH:mm:ss').valueOf()
return moment(Timestamps).format('YYYY-MM-DD HH:mm:ss')
}
export function timeToYMDm (time) {
let Timestamps = moment(time, 'YYYY-MM-DD HH:mm:ss').valueOf()
return moment(Timestamps).format('YYYY-MM-DD HH:mm')
}