How to display Time,Minute,Hour,Second in a multiple format in c# visual studio.
Display Time in multiple formats in C#
Here is an example that you can implement in your program.
Step 1- First add five labels, one timer, and a button from the toolbox and then double click on button1 and copy this following code.
private void button1_Click(object sender, EventArgs e)
{
timer1.Start();
{
DateTime now = DateTime.Now;
{
label1.Text = (now.ToString("t"));
label2.Text = (now.ToLongTimeString());
label3.Text = (now.Hour.ToString());
label4.Text = (now.Minute.ToString());
}
}
}
Step 2-Now double click on timer1 click event an copy this following code .
private void timer1_Tick_1(object sender, EventArgs e)
{
label5.Text = (DateTime.Now.Second.ToString());
label6.Text = (DateTime.Now.ToLongTimeString());
}
Here is an example that you can implement in your program.
Step 1- First add five labels, one timer, and a button from the toolbox and then double click on button1 and copy this following code.
private void button1_Click(object sender, EventArgs e)
{
timer1.Start();
{
DateTime now = DateTime.Now;
{
label1.Text = (now.ToString("t"));
label2.Text = (now.ToLongTimeString());
label3.Text = (now.Hour.ToString());
label4.Text = (now.Minute.ToString());
}
}
}
Step 2-Now double click on timer1 click event an copy this following code .
private void timer1_Tick_1(object sender, EventArgs e)
{
label5.Text = (DateTime.Now.Second.ToString());
label6.Text = (DateTime.Now.ToLongTimeString());
}
Comments
Post a Comment