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();
Label1.Text = DateTime.Now.ToString("dd/MM/yyyy");
Label1.Text = DateTime.Now.ToString();
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
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");
Tidak ada komentar:
Posting Komentar