Stop talking nonsense and get straight to the code
//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 complete 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 (the number of milliseconds since 1970.1.1)
myDate.getHours(); //Get the current hours (0-23)
MyDate.getMinutes(); //Get the current minutes (0-59)
MyDate.getSeconds(); //Get the current 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 latest 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();