I have current date in javascript like below:
self.currentDate = ko.observable(new Date());
I want to format the date in yyyy-mm-dd and use inside Sammy like below:
this.get('', function () { this.app.runRoute('get', '#'+self.currentDate()) });
There are so many long process to do it. But is there any way to do it easily. Or can i use it inside document.ready function and used it here.
Take a look at datejs.
http://www.datejs.com/
It’s a Javascript date library, which will handle your format conversion. It extends the toString method so that you can accomplish stuff like:-
There are a couple of options for integration with Knockout, but the above will “work” in returning a yyyy-mm-dd format.
Another approach, still using datejs, is to wrap the function in a ko.computed:-
If you don’t want to use datejs, you can roll your own and wrap it in a computed.
But seriously, look at datejs first. Why re-invent the wheel. Can’t really help you on the Sammy part, soz.