CSharp examples for System:DateTime Day
Convert date to milliseconds. Asserts : 1 month == 30.4375 days. No overflow verification
using System.Threading.Tasks; using System.Text; using System.Linq; using System.Collections.Generic; using System;/*from www . j a va 2s . co m*/ public class Main{ /// <summary> /// Convert date to milliseconds. Asserts : 1 month == 30.4375 days. No overflow verification /// </summary> /// <param name="dateTime">this date to convert</param> /// <returns>this as milliseconds</returns> public static long ToMillis(this DateTime dateTime) { return (long)((((((dateTime.Year * 12 + dateTime.Month - 1) * 30.4375 + dateTime.Day) * 24 + dateTime.Hour) * 60 + dateTime.Minute) * 60 + dateTime.Second) * 1000 + dateTime.Millisecond) % long.MaxValue; } }