Answer the question
In order to leave comments, you need to log in
How to convert date in jq to normal form?
Good day
Please tell me js gurus.
How to convert value to normal date?
onSelect: function(suggestion) {
console.log(suggestion);
$('.md-registration-date').text(suggestion.data.state.registration_date); //возвращает дату и выводит её в виде 1327968000000
}
});
<td><p class="md-registration-date">тут дата</p></td>
Answer the question
In order to leave comments, you need to log in
chain moment.js ( momentjs.com )
then rewrite the code:
onSelect: function(suggestion) {
console.log(suggestion);
var mDate=moment(suggestion.data.state.registration_date);
$('.md-registration-date').text(mDate.format('MMMM Do YYYY')); //возвращает форматированную дату
}
});
The best way to do these transformations is with the Moment.js library . Among other things, she also knows how to beautifully format dates and display them in any format and in any language. See examples: momentjs.com/docs/#/parsing
In your case, you need momentjs.com/docs/#/parsing/unix-offset first , and then momentjs.com/docs/#/displaying
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question