0

I'm an beginner, and I would like to know if it is possible to format a field of type date? In knockout?

  • 2
    Possible duplicate of [Knockout.js format date item](http://stackoverflow.com/questions/17148572/knockout-js-format-date-item) – JNevill Nov 30 '16 at 18:49

1 Answers1

3

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.

Community
  • 1
  • 1
El Gato
  • 31
  • 3