I`m trying to get the real date of a timestamp that comes from a gps and it seems that the formula that i found it all over the forum does not work .
I have the following code :
[code]Public Function UnixTimeToString(seconds As UInt64) as Date
Dim d As new Date
d.TotalSeconds = seconds + 2082844800
return d
End Function
[/code]
And the following timestamp “1490470593000” that on the Converter Website i get “GMT: Sat, 25 Mar 2017 19:36:33 GMT” which is correct but when i pass it to that Function and i show it as SQLDateTime i get “49201-02-18 01:10:00” so i guess there is an issue there.
I have no idea how to manage this , is there something else changed on the Date functions ?
Well, yes and no. The timestamp is too long to be seconds, and when you click the converter you linked it adds a line that says “Assuming that this timestamp is in milliseconds:”
[quote=322926:@Tim Parnell]Well, yes and no. The timestamp is too long to be seconds, and when you click the converter you linked it adds a line that says “Assuming that this timestamp is in milliseconds:”
Take off the last three zeros to get a timestamp in seconds, which when used with the method you copy and pasted from this thread: https://forum.xojo.com/8657-unix-time-to-current-date-time will work just fine.[/quote]
Hi Tim, Well the data that i`m getting is in milliseconds, so i have to do that, by cutting those 3 zeros if in case by any chance i will have a number that will not have zeros in the end what i do then ?
This is just math (1000 milliseconds = 1 second). If you are always getting milliseconds, but need seconds, then you divide the milliseconds by 1000 in order to get seconds.