Your "milliseconds" value is obviously relative to a base date/time.
By subtracting the milliseconds from the known value it is supposed to represent, we can find that base value:
DateTime baseDate = new DateTime(2022, 9, 29, 13, 48, 0, 0, DateTimeKind.Utc).AddMilliseconds(-1664459293023);
That seems like an odd choice, so I'm assuming you've simply missed out 13 seconds from your expected value. That would leave you with a base date of
1970-01-01T00:00:00Z
, which is
the Unix epoch[
^].
You will need to use that value in your calculations:
private static readonly DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
public static DateTime ConvertMillisecondsToTime(long milliseconds)
{
return UnixEpoch.AddMilliseconds(milliseconds);
}
That will give you:
DateTime DateUTCKin1 = ConvertMillisecondsToTime(TimeKin1);
NB: If the milliseconds actually represent the "Unix time", then you could use the
DateTimeOffset.FromUnixTimeMilliseconds[
^] method instead, which would give you a
DateTimeOffset
value:
DateTimeOffset DateUTCKin1 = DateTimeOffset.FromUnixTimeMilliseconds(TimeKin1);