Using Andoma's answer, this is what I do
You can create a Struct or class like this
struct Date { public static double GetTime(DateTime dateTime) { return dateTime.ToUniversalTime().Subtract(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds; } public static DateTime DateTimeParse(double milliseconds) { return new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(milliseconds).ToLocalTime(); } }
And you can use this in your code as
DateTime dateTime = DateTime.Now; double total = Date.GetTime(dateTime); dateTime = Date.DateTimeParse(total);
I hope this helps you
Pablo V May 13 '17 at 20:36 2017-05-13 20:36
source share