Search code examples
c#wpfwinformswpf-controls

How to display the current time and date in C#


How do you display the current date and time in a label in c#


Solution

  • You'd need to set the label's text property to DateTime.Now:

    labelName.Text = DateTime.Now.ToString();
    

    You can format it in a variety of ways by handing ToString() a format string in the form of "MM/DD/YYYY" and the like. (Google Date-format strings).