Gets the date of the day before the current date
? ?var MyDate = new Date( ); ?//获取昨天的日期 ? ?var yesterday = myDate.getTime()-1000*60*60*24; ? ?var date = new Date(); ? ?date.setTime(yesterday);
Get current time
date.getYear+1900=date.getFullYear()date.getMonth();//获取系统月份,由于月份是从0开始计算,所以加1date.getDate();//获取系统日date.getHours(); //获取系统时date.getMinutes(); //获取系统分date.getSeconds() ? ?//获取系统秒
Get current time
var now = new Date();获取当前时间后一天或后面一个小时的时间var now ?= new Date();now = now.setDate( now.getDate( )+1 );hour = now.setHour(now.getHours( )+1);
Gets the current timestamp (in s)
var timestamp = Date.parse(new Date())console.log(timestamp);1442825058000?function toDDMMYYYY(date){ var d = new Date(date.getTime()); var dd = d.getDate()<10 ? "0":d.getDate:d:getDate().toString(); var mmm = mths[d.getMonth()]; var yyyy = d.getFullYear().toString(); //2011 return dd+mmm+yyyy;}?function toDDMMYYYY(date){ var d = toDDMMYYYY(date); return d.substring(0,5)+d.substring(7,9);}
Date conversion to String type
JavaScript Date function