String a Date JavaScript

0

I have the following string: "1476154800000" I want to make it a date with the Date object, but I can not get it, anyway I get an error.

of this menera works:

new Date(1476154800000);

but the string is returned by a query and I can not manipulate it to remove the quotes

I appreciate the answers.

    
asked by jvilla8a 09.06.2017 в 17:56
source

1 answer

3

You just have to use the parseInt() function to pass any string to type integer ( int ), I'll give you an example:

var stringDate = "1476154800000"; // Tienes la fecha como string
var intDate = parseInt(stringDate); // La convertimos a int

var parseDate = new Date(intDate); // Creamos nuestra fecha

console.log(parseDate)
    
answered by 09.06.2017 / 17:58
source