To get only Date, Day, Month, Year or a complete Date format in C#
Here is the example you can implement this example.
Step - Add five labels and one button from the toolbox and go to the button1 click event and copy this following code.
private void button1_Click(object sender, EventArgs e)
{
DateTime dt = DateTime.Now;
label1.Text = DateTime.Now.Day.ToString();
label2.Text = DateTime.Now.DayOfWeek.ToString();
label3.Text = (dt.ToString("MMMM"));
label4.Text = (dt.ToString("yyyy"));
label5.Text = DateTime.Now.Date.ToShortDateString();
}
Here is the example you can implement this example.
Step - Add five labels and one button from the toolbox and go to the button1 click event and copy this following code.
private void button1_Click(object sender, EventArgs e)
{
DateTime dt = DateTime.Now;
label1.Text = DateTime.Now.Day.ToString();
label2.Text = DateTime.Now.DayOfWeek.ToString();
label3.Text = (dt.ToString("MMMM"));
label4.Text = (dt.ToString("yyyy"));
label5.Text = DateTime.Now.Date.ToShortDateString();
}
No comments:
Post a Comment