Sign In Register

How can we help you today?

Start a new topic
Answered

cant get correct DateTime in Unity

So I have a collection in gamesparks and a time is saved when an object is added with Date.now(). To my knowledge, that's the same as new Date() and I've tried both with no improvement.


A value I've just saved can be seen in No SQL as 

"stageTimeStartUTC": { "$date": { "$numberLong": "1469223798795" } },

and in the Test Harness Inspector as

"stageTimeStartUTC": 1469223798795,


now in unity when using

GetDate("stageTimeStartUTC")

it return Null


but using

result.GetLong("stageTimeStartUTC")

I do get 1469223798795


is this the expected result? How do I get a DateTime? It seems possible since GetDate is available.


I also tried new DateTime((long)result.GetLong("stageTimeStartUTC"), System.DateTimeKind.Utc) but that date was super wrong lol


Best Answer

How about new DateTime (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(1469223798795);


Answer

How about new DateTime (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(1469223798795);


1 person likes this

that does the trick! didnt see that the number represented that. Thanks!

Login to post a comment