mercredi 6 juillet 2016

jquery doesn't save date as timestamp on hidden value


I use JQuery to save in hidden input timestamp.

When I execute followe command:

console.log("Cur date in update function: "+cur_date);

In debug console I see: 1466946890859 This is variable (timastamp) which I put to some function. I need save this value in hidden input:

$('#dateinput').val(cur_date);

But in develop console I see that JQuery didn't save on right format:

 <input id="dateinput" type="hidden" name="date" value="Sun Jun 26 2016
 16:14:50 GMT+0300">

So, when I try in next time read this value, instead of timestamp I get format of date.

console.log("Date From hidden value: "+$('#dateinput').val());//-> show: Sun Jun 26 2016 16:14:50 GMT+0300 

How it's right fix? Save on hidden input timestamp or convert full date format to timestamp?

Thanks in advance.


Aucun commentaire:

Enregistrer un commentaire