How to convert string to long in javascript?

I have a millisecond timestamp that I need to convert from string to long. Javascript has parseInt , but not parseLong . So how can I do this?

thank

Edit: To broaden my question a bit: given that javascript apparently doesn't have a long type, how can I do simple arithmetic with longs that are initially expressed as strings? For example, subtract one from the other to get a temporary delta?

+61
javascript string long-integer unix-timestamp
Mar 27 2018-11-11T00:
source share
2 answers

JavaScript is of type Number , which is a 64-bit floating-point number *.

If you want to convert a string to a number, use

  • parseInt or parseFloat . If I use parseInt , I would recommend always passing radix.
  • use the Unary + operator, for example. +"123456"
  • use the Number constructor, for example. var n = Number("12343")

* There are situations when a number will be internally held as an integer.

+78
Mar 27 '11 at 15:02
source share

This is because there is no long in javascript.

http://javascript.about.com/od/reference/g/rlong.htm

+1
Mar 27 2018-11-11T00:
source share



All Articles