Hello, with the back end `a date comes in milliseconds from the 1970s ...

Question: How can I show this date on the site in a standard format?

  • var a = new Date(1516052901408); so tried? - Rostyslav Kuzmovych
  • Yes, thank you.) Can you tell me how to deduce from the variable a - the date format on the example: (21:32 September 28) !? - Vadym Doroshevych

2 answers 2

You can format the date like this:

 var m = [ 'Января', 'Февраля', 'Марта', 'Апреля', 'Мая', 'Июня', 'Июля', 'Августа', 'Сентября', 'Октября', 'Ноября', 'Декабря' ]; var a = new Date(1516052901408); var b = ('00' + a.getHours()).slice(-2) + ':' + ('00' + a.getMinutes()).slice(-2) + ' ' + ('00' + a.getDate()).slice(-2) + ' ' + m[a.getMonth()]; console.log(b); 

  • Thank you so much))) - Vadym Doroshevych
  • @VadymDoroshevych Not at all, but nevertheless it’s accepted instead of thanking words on this resource just to accept the answer by ticking the left above the answer - Rostyslav Kuzmovych
  • I have a new one) has not yet adapted) - Vadym Doroshevych

Perhaps this plugin will help you: https://github.com/phstc/jquery-dateFormat