L
L
Legioner9112015-10-15 16:40:21
JavaScript
Legioner911, 2015-10-15 16:40:21

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
   }
});

brings it here:
<td><p class="md-registration-date">тут дата</p></td>


thanks in advance for a good answer

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alex K, 2015-10-15
@Legioner911

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')); //возвращает форматированную дату
   }
});

D
dk-web, 2015-10-15
@dk-web

moment.js library

D
Denis Ineshin, 2015-10-15
@IonDen

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 question

Ask a Question

731 491 924 answers to any question