Reputation: 84550
I'm working on a program that uses JavaScript for scripting. Like most script systems, there's a predefined library of native functions that scripts can call into, and I just added a new one.
The new function takes a DateTime (it's in Delphi, where a DateTime is represented internally by a Double), a string and a boolean. The last two parameters come through just fine, but it appears that somewhere in the system, the time value is getting mangled. Instead of a recognizable DateTime, I get 1362394800000
, which doesn't make any sense according to Delphi's timestamp scheme.
Where can I find information on how JavaScript represents DateTime values, so I can figure out how to translate this into something my Delphi code can use? (This is using Microsoft's JScript system that comes standard with Windows 7, in case the implementation varies.)
Upvotes: 4
Views: 1216
Reputation: 324630
JavaScript represents Date objects as a number of milliseconds since the Epoch. This is important, because most other systems and languages use just integer seconds.
So assuming Delphi is one such second user, you should be able to divide the number by 1000 and pass it in.
Upvotes: 5
Reputation: 664464
JavaScript Date
values are internally represented as milliseconds since unix epoch; that's the value you get by using .getTime()
are casting the object to a number.
Upvotes: 1
Reputation: 5122
It's stored as a number of milliseconds since 1/1/1970 00:00:00.000
Upvotes: 1