Let's say that you have a JSON date in the following format
"createdDate" : "2016-03-01T13:00:00-08:00"
and you need to show on your web page created with Oracle JET.
To format the above date to a human readable format use the following javascript function:
self.getFormattedDate = function (requestedDate) {
var dateOptions = {formatStyle: 'date', dateFormat: 'long'};
var dateConverter = oj.Validation.converterFactory("datetime").createConverter(dateOptions);
var convertedDate = oj.IntlConverterUtils.dateToLocalIso(new Date(requestedDate));
return dateConverter.format(convertedDate);
};
On UI side call it as follows.
"createdDate" : "2016-03-01T13:00:00-08:00"
and you need to show on your web page created with Oracle JET.
To format the above date to a human readable format use the following javascript function:
self.getFormattedDate = function (requestedDate) {
var dateOptions = {formatStyle: 'date', dateFormat: 'long'};
var dateConverter = oj.Validation.converterFactory("datetime").createConverter(dateOptions);
var convertedDate = oj.IntlConverterUtils.dateToLocalIso(new Date(requestedDate));
return dateConverter.format(convertedDate);
};
On UI side call it as follows.
data-bind="text: getFormattedDate(createdDate)"
why createConverter show null ?
ReplyDelete