SQL receipt a result of this type: /Date(1503090145770)/
and would like to display it in date and time format.
SQL receipt a result of this type: /Date(1503090145770)/
and would like to display it in date and time format.
Apparently that value is the millisecond representation of a date.
You can create a new instance of Date();
using javascript.
Thanks to this page , we can see the following example:
console.log(new Date(1503090145770));
// Resultado:
Fri Aug 18 2017 16:02:25 GMT-0500 (Hora est. Pacífico, Sudamérica)
Thank you very much everyone for your help! In the end I managed to solve it a little as they commented to me below but with a slight modification:
var dateString = time.substr(6);
var currentTime = new Date(parseInt(dateString));
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();
var hour = currentTime.getHours();
var min = currentTime.getMinutes();
var date = day + "/" + month + "/" + year + " " + hour + ":" + min + " " + "a.m"/"p.m";
Where time is my date type: / Date (1503090145770) /. I got the digits, with parseint I passed them to the whole (since it was a string) and finally I used new Date as they suggested, thank you very much!