Reputation: 11
I'm an beginner, and I would like to know if it is possible to format a field of type date? In knockout?
Upvotes: 0
Views: 587
Reputation: 31
It's easier to try MomentJS.
Download the moment.js file, include a reference to it in your HTML file, for example
<script type="text/javascript" src="yourPath/moment.js"></script>
More info on that here. Then you can use a text binding to call moment from a span or a text box to format your date string like so:
<input type="text" data-bind="text: moment(yourDateVariable).format('DD MMM YY')"></input>
Here is another good thread with some answers, hope this helps.
Upvotes: 3