获取当前日期, 当前年月,时间戳转换年月日,时间戳转换年月日时秒,时间戳转换年月日时分秒。

// 获取当前日期
function getLocalDate() {
    var times = getYMDHMS(new Date());
    return times.year + "-" + times.month + "-" + times.date;
}

// 获取当前年月
function getLocalYearMonth() {
    var times = getYMDHMS(new Date());
    return times.year + "-" + times.month;
}
// 根据传的日期获取
function getLocalDateTime(time) {
    var times = getYMDHMS(time);
    return times.year + "-" + times.month + "-" + times.date;
}

// 时间戳转换年月日
function getAppointTime(time) {
    var timett = time * 1000;

    var times = getYMDHMS(new Date(timett));
    return times.year + "-" + times.month + "-" + times.date;
}

// 时间戳转换年月日时秒
function getAppointTimeSec(time) {
    var timett = time * 1000;

    var times = getYMDHMS(new Date(timett));
    return times.year + "-" + times.month + "-" + times.date + " " + times.hours + ":" + times.minute + ":" + times.second;
}

// 时间戳转换年月日时分秒
function getAppointTimePro(time) {
    var timett = time * 1000;
    var times = getYMDHMS(new Date(timett));
    return times.year + "-" + times.month + "-" + times.date + " " + times.hours + ":" + times.minute + ':' + times.second;
}

  

猜你喜欢

转载自www.cnblogs.com/yangsg/p/10149538.html
今日推荐