CSharp examples for System:DateTime Day
Gets End Time Of the Day
using System.Web; using System.Text.RegularExpressions; using System.Globalization; using System.Extensions; using System.Web.Mvc; using System.Threading.Tasks; using System.Text; using System.Linq; using System.Collections.Generic; using System.Collections; using System;/* www .j a v a2s . c om*/ public class Main{ /// <summary> /// Gets End Time Of the Day /// </summary> /// <param name="date">The date.</param> /// <returns></returns> public static long EndTimeOfYear(this DateTime date) { return new DateTime(date.Year, 12, DateTime.DaysInMonth(date.Year, 12), 23, 59, 59).ToUnixTimestamp(); } #endregion /// <summary> /// Converts a System.DateTime object to Unix timestamp /// </summary> /// <param name="date">The date.</param> /// <returns> /// The Unix timestamp /// </returns> public static long ToUnixTimestamp(this DateTime date) { DateTime unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0); TimeSpan unixTimeSpan = date - unixEpoch; return (long)unixTimeSpan.TotalSeconds; } }