How to convert a total os seconds to a TimeStamp?

I have a total a seconds from a defined time in the past and I need to obtain a date of this total of seconds.
The idea is to manage a virtual calendary counting virtual seconds.

You can use the DateTime and TimeSpan classes to keep track of time. You can save a DateTime in the past, then get the current DateTime to find a TimeSpan between the two.

I need is convert a quanty of seconds to a date and time.
For example if I have 1000000000 of seconds I need to have with is the date from the begining of the times…

By default a new DateTime starts out at {01/01/0001 00:00:00}

You can then call AddSeconds(1000000000) to get the current date time.

1 Like

public string ConvertToTimestamp(long unixTime)
{
DateTime unixStart = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc).ToLocalTime() ;// hour local zone
long unixTimeStampInTicks = (unixTime * TimeSpan.TicksPerMillisecond);
string date = new DateTime(unixStart.Ticks + unixTimeStampInTicks, System.DateTimeKind.Utc).ToString();
return date;
}