How should I convert timestamp in unity, which is a double, in a webserver-like BIGINT number ?

Sorry for the newbee question>

I see timestamp property (in MessageInfo or LocationInfo unity structures) is of type: Double.

But I always used BIG INT time stamp such as 1315990560

What should I do to convert that Double floating point number into a proper int timestamp ?

For future searchers! This is how you get time as timestamp in Unity:

long time = new DateTimeOffset(DateTime.Now).ToUnixTimeSeconds();

It will give you something like this: 1563280100.

Tested in Unity 2019

This page may help: DateTime Struct (System) | Microsoft Learn Also How to get 'real' time? - Questions & Answers - Unity Discussions

I try to be more specific.

Talking about a mobile App, that need to retrieve the geographical position from GPS.

Asking the timestamp to GPS locationInfo with Unity built-in new commands (Unity Android Pro version 3.4) I get this kind of numbers:


But I think there is no convertion algorithm around to convert this DOUBLE into a BIG INT usual UNIX TIMESTAMP.

What Am I missing ?

Please try this:

private double ConvertToTimestamp(DateTime value)
    //create Timespan by subtracting the value provided from
    //the Unix Epoch
    TimeSpan span = (value - new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime());

    //return the total seconds (which is a UNIX timestamp)
    return (double)span.TotalSeconds;

I did that and is working;

private double ConvertToToTimestamp(System.DateTime value)
		double timeStamp = (System.DateTime.UtcNow - value).TotalSeconds; 
		return timeStamp;