Kamis, 02 Januari 2014

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

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

Tidak ada komentar:

Posting Komentar