2016-01-29

How to calculate yesterday day in JavaScript?

I needed to calculate 'day before' with Javascript. As this is trivial task for C#, I needed to lookup to stackoverflow for the solution. Solution is here:
var date = new Date();

date ; //# => Fri Apr 01 2011 11:14:50 GMT+0200 (CEST)

date.setDate(date.getDate() - 1);

date ; //# => Thu Mar 31 2011 11:14:50 GMT+0200 (CEST)
Reference: http://stackoverflow.com/questions/5511323/javascript-yesterday

No comments:

Post a Comment