js yesterday date

JavaScript
var d = new Date();
d.setDate(d.getDate() - 1);
var yesterday = new Date((new Date()).valueOf() - 1000*60*60*24);

Source

Also in JavaScript: