Error:

Get current time

var d = new Date();
var hh = d.getHours();
var mm = d.getMinutes();
var ss = d.getSeconds();

Get current date

var d = new Date();
var year = d.getFullYear();
// 0 - January, etc...
var month = d.getMonth();
// 1..31
var day = d.getDate();

Convert date to epoch seconds

// epoch time for Nov 19th, 2013 21:59:59
var d = new Date(2013, 10, 19, 21, 59, 59);
var epoch = Math.round(d.getTime()/1000);

Convert epoch seconds to date

var epoch = 1384898399;
// d is Date obect for Tue Nov 19 2013 13:59:59 GMT-0800 (PST)
var d = new Date(epoch*1000);

Add to date

Date.prototype.addHours = function(h) {
   var d = new Date();    
   d.setTime(this.getTime() + (h*60*60*1000)); 
   return d;   
}

var d = new Date();
var inAnHour = d.addHours(1);

Substract from date

Date.prototype.addHours = function(h) {
   var d = new Date();    
   d.setTime(this.getTime() + (h*60*60*1000)); 
   return d;   
}

var d = new Date();
var backAnHour = d.addHours(-1);

Difference between two dates

// Dec 19th
var d1 = new Date(2012, 11, 19);
var d2 = new Date(2013, 11, 19);

// days is 365
var days = Math.round((d2.getTime() - d1.getTime())/1000/(24*60*60));

Get week number for the date

Date.prototype.getWeek = function() {
    var jan1 = new Date(this.getFullYear(),0,1);
    return Math.ceil((((this - jan1) / (24*60*60*1000)) + jan1.getDay()+1)/7);
} 

var d = new Date(2012, 10, 19);
// 47th week
var week = d.getWeek();

Get day number in a year for the date

Date.prototype.getYearDay = function() {
    var jan1 = new Date(this.getFullYear(),0,1);
    return Math.ceil((this.getTime() - jan1.getTime())/(24*60*60*1000)) + 1;
} 

var d = new Date(2013, 10, 19);
// 323
var day = d.getYearDay();

Get day number in a week for the date

var d = new Date(2013, 10, 19);
// 2 for Tue
var weekDay = d.getDay();

Parse date from the string

// milliseconds from epoch
var epoch = Date.parse("Aug 19, 1991");
var d = new Date(epoch);