Login or Sign Up to become a member!
LessThanDot Sit Logo

LessThanDot

Community Wiki

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot friendfeed Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Navigation

Google Ads

ASP.NET: Simple date and time methods

From Wiki

Jump to: navigation, search


Summary: A list of simple date and time methods

  1. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  2.     Response.Write(System.DateTime.Now & " - Today's date and time<br>")
  3.     Response.Write(System.DateTime.Today & " - Today's date<br>")
  4.     Response.Write(System.DateTime.Now.ToString("hh:mm:ss") & " - Today's time 12 hour format<br>")
  5.     Response.Write(System.DateTime.Now.ToString("HH:mm:ss") & " - Today's time 24 hour format<br>")
  6.     Response.Write(System.DateTime.Now.AddDays(1) & " - Tomorrow's date and time<br>")
  7.     Response.Write(System.DateTime.Now.AddMonths(1) & " - Next month's date and time<br>")
  8.     Response.Write(System.DateTime.Now.AddDays(-1) & " - Yesterday's date and time<br>")
  9.     Response.Write(System.DateTime.Now.AddMonths(-1) & " - Last months date and time<br>")
  10.     Response.Write(System.DateTime.Now.AddYears(1) & " - Next years date and time<br>")
  11.     Response.Write(System.DateTime.Now.DayOfWeek & " - Today's day of the week<br>")
  12.     Response.Write(System.DateTime.Now.DayOfYear & " - Today's day of the year<br>")
  13.     Response.Write(System.DateTime.Now.Year & " - The current year<br>")
  14.     Response.Write(System.DateTime.Now.Month & " - The current month<br>")
  15.     Response.Write(System.DateTime.Now.ToString("MMMM") & " - The current full month name<br>")
  16.     Response.Write(System.DateTime.Now.ToString("MMM") & " - The current short month name<br>")
  17.     Response.Write(System.DateTime.Now.Day & " - The current day<br>")
  18.     Response.Write(System.DateTime.Now.Hour & " - The current hour<br>")
  19.     Response.Write(System.DateTime.Now.Minute & " - The current minute<br>")
  20.     Response.Write(System.DateTime.Now.Second & " - The current second<br>")
  21. End Sub


This Hack is part of the ASP.NET Hacks collection

475 Rating: 2.8/5 (8 votes cast)