Converts the date to an Epoch of milliseconds since 197011. - CSharp System

CSharp examples for System:DateTime Second

Description

Converts the date to an Epoch of milliseconds since 197011.

Demo Code

// Copyright by the Spark Development Network
using System;//from w  w  w  .  j  a  v a  2 s  . c om

public class Main{
        /// <summary>
        /// Converts the date to an Epoch of milliseconds since 1970/1/1.
        /// </summary>
        /// <param name="dateTime">The date time.</param>
        /// <returns></returns>
        public static long ToJavascriptMilliseconds( this DateTime dateTime )
        {
            return (long)( dateTime.ToUniversalTime() - new DateTime( 1970, 1, 1 ) ).TotalMilliseconds;
        }
}

Related Tutorials