Search

Thursday, January 2, 2014
0 comments

Computer Programming : Different DateTime format in ASP.NET, Example

1:01 AMThursday, January 2, 2014
DateTime class is used to print date and time of the system/server. Its very useful class in application development or project development. Suppose you want to print current date and time of the system, use DateTime class with Now property.

Label1.Text = DateTime.Now.ToString();


Dotprogramming : Print current date and time
If you want to print only date with special format like date/month/year. Now, use dd/MM/yyyy in ToString() method. Lets take an simple example

Label1.Text = DateTime.Now.ToString("dd/MM/yyyy");

Dotprogramming : print date with specific format

 Similarly again, if you want to print only day of current date then you should take only "dd" in the string parameter.

Label1.Text = DateTime.Now.ToString("dd");

day of the current datetime in asp.net

Protected by Copyscape Online Copyright Protection Software

0 comments :

Post a Comment

 
Toggle Footer
Top