ASP.NET: Simple date and time methods
From Wiki
Summary: A list of simple date and time methods
- Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
- Response.Write(System.DateTime.Now & " - Today's date and time<br>")
- Response.Write(System.DateTime.Today & " - Today's date<br>")
- Response.Write(System.DateTime.Now.ToString("hh:mm:ss") & " - Today's time 12 hour format<br>")
- Response.Write(System.DateTime.Now.ToString("HH:mm:ss") & " - Today's time 24 hour format<br>")
- Response.Write(System.DateTime.Now.AddDays(1) & " - Tomorrow's date and time<br>")
- Response.Write(System.DateTime.Now.AddMonths(1) & " - Next month's date and time<br>")
- Response.Write(System.DateTime.Now.AddDays(-1) & " - Yesterday's date and time<br>")
- Response.Write(System.DateTime.Now.AddMonths(-1) & " - Last months date and time<br>")
- Response.Write(System.DateTime.Now.AddYears(1) & " - Next years date and time<br>")
- Response.Write(System.DateTime.Now.DayOfWeek & " - Today's day of the week<br>")
- Response.Write(System.DateTime.Now.DayOfYear & " - Today's day of the year<br>")
- Response.Write(System.DateTime.Now.Year & " - The current year<br>")
- Response.Write(System.DateTime.Now.Month & " - The current month<br>")
- Response.Write(System.DateTime.Now.ToString("MMMM") & " - The current full month name<br>")
- Response.Write(System.DateTime.Now.ToString("MMM") & " - The current short month name<br>")
- Response.Write(System.DateTime.Now.Day & " - The current day<br>")
- Response.Write(System.DateTime.Now.Hour & " - The current hour<br>")
- Response.Write(System.DateTime.Now.Minute & " - The current minute<br>")
- Response.Write(System.DateTime.Now.Second & " - The current second<br>")
- End Sub
This Hack is part of the ASP.NET Hacks collection


