JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://ajax.aspnetcdn.com/ajax/globalize/0.1.1/globalize.min.js"></script>
<div data-bind="text: dates"></div>
<div data-bind="text: raw"></div>
JavaScript
ko.extenders.date = function(target, format) {
var raw = ko.observable();
var result = ko.computed({
read: function() {
var value = target();
if(typeof value === "string") {
value = new Date(value);
}
raw(value);
format = typeof format === "string" ? format: undefined;
value = Globalize.format(value, format);
return value;
},
write: target
});
result.raw = raw;
return result;
}
ViewModel = function() {
this.dates = ko.observable("2013-06-17T11:56:18.4537687Z").extend({ date: true });
this.raw = this.dates.raw;
}
ko.applyBindings(new ViewModel());