I want to display current time on a label using C# but time will continuously change as system time changes. How can I do this?
You can get the current time using something like DateTime. Now . Save this answer.
C# today's date Now; Console. WriteLine(now. ToString("F")); The example prints today's date.
Add a new Timer control to your form, called Timer1, set interval to 1000 (ms), then double click on the Timer control to edit the code-behind for Timer1_Tick and add this code:
this.label1.Text = DateTime.Now.ToString();
You can Add a timer control and specify it for 1000 millisecond interval
private void timer1_Tick(object sender, EventArgs e)
{
lblTime.Text = DateTime.Now.ToString("dd-MMM-yyyy hh:mm:ss tt");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With