Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
172
rated 0 times [  174] [ 2]  / answers: 1 / hits: 22870  / 9 Years ago, mon, august 10, 2015, 12:00:00

I am using date-format package in node back end and I can get today date using



var today = dateFormat(new Date());


In the same or some other way I want yesterday date. Still I did't get any proper method. For the time being I am calculating yesterday date manually with lot of code. Is there any other method other then writing manually ?


More From » node.js

 Answers
21

Try this:



var d = new Date(); // Today!
d.setDate(d.getDate() - 1); // Yesterday!

[#65475] Friday, August 7, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
margaritakristinak

Total Points: 502
Total Questions: 127
Total Answers: 98

Location: England
Member since Mon, May 17, 2021
3 Years ago
;