Im trying to convert a value of milliseconds to a readable date format.
I have tried to search for the solution, but there is not an answer that fixes my problem.
Im trying to get val.start
to output like this 10.15
, now it is outputting: 1413363600000
My code:
(function($) {
var options = {
//Some options removed for question
onAfterEventsLoad: function(events) {
if(!events) {
return;
}
var list = $('#eventlist');
list.html('');
$.each(events, function(key, val) {
$(document.createElement('li'))
.html(' + val.start + ': ' + val.title + ')
.appendTo(list);
});
},
};
var calendar = $('#calendar').calendar(options);
}(jQuery));
I have tried to use momentjs like this:
var start_date = moment.unix(val.start).format("MM.DD");
But this is giving the wrong date: 09.17
(should be 10.15
)
您能尝试一下吗,瞬间lib可能需要几秒钟而不是ms
moment.unix(val.start/1000).format("MM.DD");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.