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

January 02, 2014 0 Comments

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

Jacob Lefore

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard. Google