UNPKG

megautils-js

Version:

## Project Description

50 lines (44 loc) 1.35 kB
/** * @file 日期类工具 */ const commonUtils = require("./commonUtils") module.exports = { // MARK - Public // ************************************************************************ /** * @func 获取当前年份 * * @return {Integer}: year */ getCurrentYear() { var date = new Date var year = date.getFullYear() return year }, /** * @func 获取当前日期(短字符串) * 获取当前时间 格式:yyyyMMdd * @returns */ dateNowDateShortString() { var date = new Date(); //当前时间 var month = commonUtils.zeroFill(date.getMonth() + 1); //月 var day = commonUtils.zeroFill(date.getDate()); //日 //当前时间 var curTime = "" + date.getFullYear() + month + day return curTime; }, /** * @func 获取当前日期(字符串) * 获取当前时间 格式:yyyy-MM-dd * @returns */ dateNowDateString() { var date = new Date(); //当前时间 var month = commonUtils.zeroFill(date.getMonth() + 1); //月 var day = commonUtils.zeroFill(date.getDate()); //日 //当前时间 var curDate = date.getFullYear() + "-" + month + "-" + day return curDate } }