Returns the current unix timestamp in milliseconds (UTC). - CSharp System

CSharp examples for System:DateTime Second

Description

Returns the current unix timestamp in milliseconds (UTC).

Demo Code


using System.Threading.Tasks;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;//from   w w  w  .  j a va2  s .co  m

public class Main{
        /// <summary>
        ///     Returns the current unix timestamp in milliseconds (UTC).
        /// </summary>
        /// <returns></returns>
        public static long GetCurrentTimestampInMilliseconds()
        {
            return (long)(DateTime.UtcNow - _posixTime).TotalMilliseconds;
        }
}

Related Tutorials