In ASP.Net VB DateTime object of System Date Structure that provides the functions and properties to get the server DateTime in different format. ASP.Net VB DateTime consists of Now property that can be accessed directly in the code to get the current instance of Date and time of the Server. You can also customize the VB DateTime output into your required formats such as MM-dd-yyyy, dd/MM/yyyy etc. Here we will learn the use of inbuilt functions of DateTime to retrieve the current Date and Time on the Server.
' Displays the current Date and Time
Response.Write(DateTime.Now())
Response.Write("<br>")
' Displays current time span of the day
Response.Write(DateTime.Now.TimeOfDay())
' Displays Short Time string in hh:mm tt format
Response.Write(DateTime.Now.ToShortTimeString())
' Displays Long Time string in hh:mm:ss tt format
Response.Write(DateTime.Now.ToLongTimeString())
' Displays Long Date String in dddd, MMMM dd, yyyy format
Response.Write(DateTime.Now.ToLongDateString())
Above ASP.Net VB DateTime Functions return the following output:
7/22/2008 12:11:04 PM 12:11:04.0968750 12:11 PM 12:11:04 PM Tuesday, July 22, 2008 7/22/2008
Be the first to rate this post
Tags: asp.net 2.0, vb datetime, asp.net datetime, vb current datetime, asp.net datetime format, free source code, c# datetime, asp.net vb datetime, asp.net c# datetime
10/11/2008 3:23:10 AM