Less nonsense, just upload the code
The code copy is as follows:
//Get the current time:
var myDate = new Date();//Current time
var year = myDate.getFullYear();//Current year
var month = myDate.getMonth() + 1;//Current month
var day = myDate.getDate();//Current day
myDate.getYear(); //Get the current year (2 digits)
myDate.getFullYear(); //Get the full year (4 digits, 1970-????)
myDate.getMonth(); //Get the current month (0-11, 0 represents January)
myDate.getDate(); //Get the current day (1-31)
myDate.getDay(); //Get the current week X (0-6, 0 represents Sunday)
myDate.getTime(); //Get the current time (number of milliseconds starting from 1970.1.1)
myDate.getHours(); //Get the current number of hours (0-23)
myDate.getMinutes(); //Get the current number of minutes (0-59)
myDate.getSeconds(); //Get the current number of seconds (0-59)
myDate.getMilliseconds(); //Get the current number of milliseconds (0-999)
myDate.toLocaleDateString(); //Get the current date
var mytime=myDate.toLocaleTimeString(); //Get the current time
myDate.toLocaleString( ); //Get date and time
var oneDay = 1000 * 60 * 60 * 24;
//Get the date of the last week
var lastDate = new Date(myDate - oneDay * 6);
var lastYear = lastDate.getFullYear();
var lastMonth = lastDate.getMonth() + 1;
var lastDay = lastDate.getDate();
//Get the last day of the current month
var day = new Date(year ,month , 0);
var lastdate = day.getDate();//The last day of the current month
//Get the date of the last N months
var lastDate = new Date(myDate - oneDay * myDate.getDate());
lastDate = new Date(lastDate - N * oneDay * (lastDate.getDate() - 1));
var lastYear = lastDate.getFullYear();
var lastMonth = lastDate.getMonth() + 1;
var lastDay = lastDate.getDate();
//Convert string to timestamp
var date="2014-12-06";
date = new Date(Date.parse(date.replace(/-/g, "/")));
date = date.getTime();