// 时间戳转换-年月日
export function formatDate_ymd(timestamp) {
var newDate = new Date(timestamp* 1000);
var YY = newDate.getFullYear() + '/';
var MM = (newDate.getMonth() + 1 < 10 ? '0' + (newDate.getMonth() + 1) : newDate.getMonth() + 1) + '/';
var DD = (newDate.getDate() < 10 ? '0' + (newDate.getDate()) : newDate.getDate());
let times = YY + MM + DD
return times;
}
// 时间戳转换-年月日
export function formatDate_ymd_1(timestamp) {
//timestamp时间戳
var newDate = new Date();
newDate.setTime(timestamp * 1000);
// 2018/5/28
return newDate.toLocaleDateString();
}
// 时间戳转换-年月日时分秒
export function formatDate_ymd_hms(timestamp) {
var newDate = new Date(timestamp* 1000);
var YY = newDate.getFullYear() + '-';
var MM = (newDate.getMonth() + 1 < 10 ? '0' + (newDate.getMonth() + 1) : newDate.getMonth() + 1) + '-';
var DD = (newDate.getDate() < 10 ? '0' + (newDate.getDate()) : newDate.getDate());
var hh = (newDate.getHours() < 10 ? '0' + newDate.getHours() : newDate.getHours()) + ':';
var mm = (newDate.getMinutes() < 10 ? '0' + newDate.getMinutes() : newDate.getMinutes()) + ':';
var ss = (newDate.getSeconds() < 10 ? '0' + newDate.getSeconds() : newDate.getSeconds());
let times = YY + MM + DD +" "+hh + mm + ss;
return times;
}
// 时间戳转换-时分秒
export function formatDate_hms(timestamp) {
var newDate = new Date(timestamp* 1000);
var hh = (newDate.getHours() < 10 ? '0' + newDate.getHours() : newDate.getHours()) + ':';
var mm = (newDate.getMinutes() < 10 ? '0' + newDate.getMinutes() : newDate.getMinutes()) + ':';
var ss = (newDate.getSeconds() < 10 ? '0' + newDate.getSeconds() : newDate.getSeconds());
let times = hh + mm + ss;
return times;
}
// 获取取当前时间-时分秒
export function nowDate_hms() {
var newDate = new Date();
var hh = (newDate.getHours() < 10 ? '0' + newDate.getHours() : newDate.getHours()) + ':';
var mm = (newDate.getMinutes() < 10 ? '0' + newDate.getMinutes() : newDate.getMinutes()) + ':';
var ss = (newDate.getSeconds() < 10 ? '0' + newDate.getSeconds() : newDate.getSeconds());
let times = hh + mm + ss;
return times;
}
// 获取取当前时间-年月日
export function nowDate_ymd() {
var newDate = new Date();
var YY = newDate.getFullYear() + '-';
var MM = (newDate.getMonth() + 1 < 10 ? '0' + (newDate.getMonth() + 1) : newDate.getMonth() + 1) + '-';
var DD = (newDate.getDate() < 10 ? '0' + (newDate.getDate()) : newDate.getDate());
let times = YY + MM + DD;
return times;
}
// 获取取当前时间-年月日
export function nowDate_ymd_hms() {
var newDate = new Date();
var YY = newDate.getFullYear() + '-';
var MM = (newDate.getMonth() + 1 < 10 ? '0' + (newDate.getMonth() + 1) : newDate.getMonth() + 1) + '-';
var DD = (newDate.getDate() < 10 ? '0' + (newDate.getDate()) : newDate.getDate());
var hh = (newDate.getHours() < 10 ? '0' + newDate.getHours() : newDate.getHours()) + ':';
var mm = (newDate.getMinutes() < 10 ? '0' + newDate.getMinutes() : newDate.getMinutes()) + ':';
var ss = (newDate.getSeconds() < 10 ? '0' + newDate.getSeconds() : newDate.getSeconds());
let times = YY + MM + DD +" "+hh + mm + ss;
return times;
}
// excel时间名字
export function nowDate_excel_name() {
var newDate = new Date();
var YY = newDate.getFullYear() + '-';
var MM = (newDate.getMonth() + 1 < 10 ? '0' + (newDate.getMonth() + 1) : newDate.getMonth() + 1) + '-';
var DD = (newDate.getDate() < 10 ? '0' + (newDate.getDate()) : newDate.getDate());
var hh = (newDate.getHours() < 10 ? '0' + newDate.getHours() : newDate.getHours()) + '-';
var mm = (newDate.getMinutes() < 10 ? '0' + newDate.getMinutes() : newDate.getMinutes()) + '-';
var ss = (newDate.getSeconds() < 10 ? '0' + newDate.getSeconds() : newDate.getSeconds());
let times = YY + MM + DD +"-"+hh + mm + ss;
return times;
}
// 初始化当前时间-时分秒
export function initDate_hms(newDate) {
var hh = (newDate.getHours() < 10 ? '0' + newDate.getHours() : newDate.getHours());
var mm = (newDate.getMinutes() < 10 ? '0' + newDate.getMinutes() : newDate.getMinutes());
var ss = (newDate.getSeconds() < 10 ? '0' + newDate.getSeconds() : newDate.getSeconds());
let times = hh + mm + ss;
return {hh , mm , ss};
}
// 初始化当前时间-年月日
export function initDate_ymd(newDate) {
var YY = newDate.getFullYear();
var MM = (newDate.getMonth() + 1 < 10 ? '0' + (newDate.getMonth() + 1) : newDate.getMonth() + 1);
var DD = (newDate.getDate() < 10 ? '0' + (newDate.getDate()) : newDate.getDate());
let times = YY + MM + DD;
return {YY , MM , DD};
}
// 初始化当前时间-年月日
export function initDate_ymd_hms(newDate) {
var YY = newDate.getFullYear() + '-';
var MM = (newDate.getMonth() + 1 < 10 ? '0' + (newDate.getMonth() + 1) : newDate.getMonth() + 1) + '-';
var DD = (newDate.getDate() < 10 ? '0' + (newDate.getDate()) : newDate.getDate());
var hh = (newDate.getHours() < 10 ? '0' + newDate.getHours() : newDate.getHours()) + ':';
var mm = (newDate.getMinutes() < 10 ? '0' + newDate.getMinutes() : newDate.getMinutes()) + ':';
var ss = (newDate.getSeconds() < 10 ? '0' + newDate.getSeconds() : newDate.getSeconds());
let times = YY + MM + DD +" "+hh + mm + ss;
return times;
}