Calculates the Unix epoch minutes for the date - CSharp System

CSharp examples for System:DateTime Unix

Description

Calculates the Unix epoch minutes for the date

Demo Code


using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*from ww  w  .  j av a  2 s  . c  om*/

public class Main{
        /// <summary>
        /// Calculates the Unix epoch minutes for the date
        /// </summary>
        /// <returns>The Unix epoch minutes</returns>
        public static long ToUnixEpochMinutes(this DateTime date)
        {
            return date.ToUnixEpoch() / 60;
        }
        /// <summary>
        /// Calculates the Unix epoch for the date
        /// </summary>
        /// <returns>The Unix epoch</returns>
        public static long ToUnixEpoch(this DateTime date)
        {
            return (date.Ticks - 621355968000000000) / 10000000;
        }
}

Related Tutorials