akeeseth
akeeseth

Reputation: 845

Pastdate in knockoutjs

I want to get past day dates(like yesterday) in knockout. To get current date i have written like below:

self.currentDate = ko.observable(new Date().toString('yyyy-M-dd'))

But how to get date of yesterday here??

Upvotes: 1

Views: 623

Answers (1)

sphair
sphair

Reputation: 1670

Without testing with the date.js library, but maybe something like this could work:

var yesterday = Date.today().addDays(-1);
self.currentDate = ko.observable(yesterday.toString('yyyy-M-dd'));

Upvotes: 1

Related Questions