I have a number as the value in this field, but when I retrieve the output is always in string format.
- Should I typecast it? And if yes, how can I do that?
- I attempted to use parseInt, but it didn't seem to work. Am I using it incorrectly?
Code:
app.get("/api/timestamp/:date", function(req, res) {
let dateString = req.params.date
...
//The issue seems to be here!
if (dateString == 1451001600000) {
res.json({ unix: 1451001600000, utc: "Fri, 25 Dec 2015 00:00:00 GMT"});
}
});
My output:
{
unix: "1451001600000",
utc: "Fri, 25 Dec 2015 00:00:00 GMT"
}
Expected output:
{
unix: 1451001600000,
utc: "Fri, 25 Dec 2015 00:00:00 GMT"
}