Returns the number of milliseconds since January 1, 1970, 00:00:00 UTC | developer.brewmp.com Returns the number of milliseconds since January 1, 1970, 00:00:00 UTC | developer.brewmp.com

Developer

Returns the number of milliseconds since January 1, 1970, 00:00:00 UTC

Forums:

Hi,

I want to return Returns the number of milliseconds since January 1, 1970, 00:00:00 UTC (my server is using this as the base time to start calculation), does BREW support that? GETTIMESECONDS() only returns No. of MS since Jan. 6, 1980.

If not, what is the next best way to do this? Code example would be great.

Thanks.

Add the number of milliseconds between Jan 1, 1970 and Jan 6, 1980?
GETTIMESECONDS returns the number of seconds since Jan 6, 1980. GETTIMESECONDS() - LOCALTIMEOFFSET(NULL) + 284428809 should give you the number of seconds since Jan 1, 1970 UTC.
If you really want milliseconds, I haven't done the math but it could be possible. You'll need to use 64 bits since 2^32 ms runs out in ~49 days. And I don't know how accurate it will be, there might be a measurable amount of drift from the carrier's time base. There's also the question of finding the number of ms between Jan 6, 1980 and midnight today. Depending on what you need, it may be best to just get the number of seconds and multiply by 1000 (not using 32-bit numbers, of course).

Add the number of milliseconds between Jan 1, 1970 and Jan 6, 1980?
GETTIMESECONDS returns the number of seconds since Jan 6, 1980. GETTIMESECONDS() - LOCALTIMEOFFSET(NULL) + 284428809 should give you the number of seconds since Jan 1, 1970 UTC.
If you really want milliseconds, I haven't done the math but it could be possible. You'll need to use 64 bits since 2^32 ms runs out in ~49 days. And I don't know how accurate it will be, there might be a measurable amount of drift from the carrier's time base. There's also the question of finding the number of ms between Jan 6, 1980 and midnight today. Depending on what you need, it may be best to just get the number of seconds and multiply by 1000 (not using 32-bit numbers, of course).