long ToUnixTimestamp(System.DateTime dt){ DateTime unixRef = new DateTime(1970, 1, 1, 0, 0, 0); return (dt.Ticks - unixRef.Ticks) / 10000000; } DateTime FromUnixTimestamp(long timestamp){ DateTime unixRef = new DateTime(1970, 1, 1, 0, 0, 0); return unixRef.AddSeconds(timestamp); }