To Javascript Timestamp - CSharp System

CSharp examples for System:DateTime Timestamp

Description

To Javascript Timestamp

Demo Code


using System.Web;
using System.Linq;
using System.Collections.Generic;
using System;/*from   w ww.ja v  a 2s.  com*/

public class Main{
        public static long ToJavascriptTimestamp(this DateTime input)
        {
            TimeSpan span = new TimeSpan(new DateTime(1970, 1, 1, 0, 0, 10).Ticks);
            DateTime time;

            if (input.Kind == DateTimeKind.Utc)
            {
                time = input.Subtract(span);
            }
            else
            {
                time = input.ToUniversalTime().Subtract(span);
            }
            return (long)(time.Ticks / 10000);
        }
}

Related Tutorials