talk is cheap,show me the code! //获取昨天 var day1 = new Date(); day1.setTime(day1.getTime()-24*60*60*1000); var yesterDate = day1.getFullYear()+"/" + (day1.getMonth()+1) + "/" + day1.getDate(); //获取当前日期 var date = new Date(); var year =
function formatDate (val) { // 格式化时间 let start = new Date(val) let y = start.getFullYear() let m = (start.getMonth() + 1) > 10 ? (start.getMonth() + 1) : '0' + (start.getMonth() + 1) let d = start.getDate() > 10 ? start.getDate() : '0' + start.getDa
var datetime = new Date(); var year = datetime.getFullYear(); var month = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1) : datetime.getMonth() + 1; var date = datetime.getDate() < 10 ? "0" + datetime.getDate() : d
//obtain timestamp of last week var now=new Date() var nowDayOfWeek = now.getDay(); //今天本周的第几天 var nowDay = now.getDate(); //当前日 var nowMonth = now.getMonth(); //当前月 var nowYear = now.getFullYear(); //当前年 //obtain time of last month var lastMonthDate
/** * 获取系统当前时间 */ function getNowYearMouth(){ var date=new Date; var nowYearMouth=date.getMonth()+1; var year=date.getFullYear(); var day = date.getDate(); nowYearMouth =(nowYearMouth<10 ? "0"+nowYearMouth:nowYearMouth); //获取当前时间----月份 var no
JS获取当前日期时间 var date = new Date(); date.getYear(); //获取当前年份(2位) date.getFullYear(); //获取完整的年份(4位,2014) date.getMonth(); //获取当前月份(0-11,0代表1月) date.getDate(); //获取当前日(1-31) date.getDay(); //获取当前星期X(0-6,0代表星期天) date.getTime(); //获取当前时间(从1970.1.1开始的毫秒数) d