I am getting date from in this format "/Date(1471846675177+0000)/"
I have done this :
var longToDate=function(millisec){
var length=millisec.length-7;
var date=millisec.substring(6,length);
return (new Date(millisec.substring(6,length)).toUTCString());
}
But it is showing "invalid date". Can someone tell me the reason for it ?
you forgot parseInt
var longToDate = function(millisec) {
var length = millisec.length - 7;
var date = parseInt(millisec.substring(6,length));
return (new Date(date).toUTCString());
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With