CSharp examples for System:DateTime Hour
Will give you the DateTime object given the number of hours you go back.
using System;/* w w w .java2 s . c o m*/ public class Main{ /// <summary> /// Will give you the DateTime object given the number of hours you go back. /// </summary> /// <param name="hours"> /// The days. /// </param> /// <returns> /// DateTime object /// </returns> public static DateTime HoursAgo(this int hours) { var t = new TimeSpan(hours, 0, 0); return DateTime.Now.Subtract(t); } }