Knockout.js format date item

前端 未结 5 1584
轻奢々
轻奢々 2020-12-15 03:49

In my view I wish to display a knockout.js binded field that contains a date. It is just a display field and not an input field. Something like below when

5条回答
  •  借酒劲吻你
    2020-12-15 04:23

    If you are referencing moment.js then I would actually format in the knockout model.

    var BiographicViewModel = function (person) {
        this.FirstName = ko.observable(person.first_name);
        this.LastName = ko.observable(person.last_name);
        this.DOB = ko.observable(moment(person.birth_date).format("MM/DD/YYYY"));
        this.Gender = ko.observable(person.gender);
        this.Country = ko.observable(person.country);
        this.City = ko.observable(person.city);        
    };
    

提交回复
热议问题