CSharp examples for System:DateTime Day
Is Today
using System.Threading.Tasks; using System.Text; using System.Linq; using System.Collections.Generic; using System;// w ww. j ava 2s.co m using HandyWork.Common.Time; public class Main{ public static bool IsToday(this DateTime? dt) { return dt == null ? false : dt.Value.IsToday(); } public static bool IsToday(this DateTime dt) { return dt.ToDayString().Equals(DateTime.Now.ToDayString()); } /// <summary> /// yyyy-MM-dd /// </summary> public static string ToDayString(this DateTime? dt) { return dt == null ? null : dt.Value.ToDayString(); } /// <summary> /// yyyy-MM-dd /// </summary> public static string ToDayString(this DateTime dt) { return dt.ToString(Formats.ToDay); } }