1
How to convert this sequence of numbers: 1555506548000 into a valid date ?
I need to make the following comparison:
if (_valor[0] == item.DT_CRIADO_EM) {
//Faz alguma coisa
};
However the date is not in the desired format as described above. It follows the relevant code snippet:
Response from AJAX
success: function (response) {
$.each(response.emailList, function (index, item) {
console.log("item.DT_CRIADO_EM: " + item.DT_CRIADO_EM); // <<--- item.DT_CRIADO_EM: /Date(1555506548000)/
$("input[name='txtData[]']").each(function () {
var _valor = new Array();
_valor.push($(this).data("dt_criado_em"));
console.log("_valor[]: " + _valor[0]); // <<--- _valor[]: 15/04/2019 00:00:00
if (_valor[0] == item.DT_CRIADO_EM) { // <<--- Preciso comparar as duas datas aqui
//Faz alguma coisa
};
});
});
},
Possible duplicate of Convert timestamp value to date
– Ricardo Pontual
Download this Datelocale.js plugin ?
– hard123
pf read the answer
– Ricardo Pontual
Excuse my ignorance but I need more help, I have read the answer and implemented the code and gives error lock visual studio: var date = new Date(1555506548000 * 1000);
– hard123
The value of
item.DT_CRIADO_EM
is exactly this (a string with bars and everything):/Date(1555506548000)/
?– Sam
Exactly @Sam ! I updated the post and added a console print.
– hard123
do not need to download the plugin, just use the code that is in the answer:
var data = new Date(1555506548000).toLocaleDateString("pt-BR")
, and if you want to validate, only one valuealert(data);
– Ricardo Pontual