Format Time
-
How do I format time so that it will show in terms of
HH:MM
only ? I am using this:this.statusBar1.Text = DateTime.Now.TimeOfDay.ToString();
and the time is not in the right format. Thanks in advance. Nick Parker
-
How do I format time so that it will show in terms of
HH:MM
only ? I am using this:this.statusBar1.Text = DateTime.Now.TimeOfDay.ToString();
and the time is not in the right format. Thanks in advance. Nick Parker
DateTime.Now.ToString("HH:mm") should do it. "hh:mm" for a 12 hour clock. There is also DateTime.Now.ToString("t") and DateTime.Now.ToShortTimeString(), the latter just turns around and executes the former. These last two are locale/culture aware. Regards
-
DateTime.Now.ToString("HH:mm") should do it. "hh:mm" for a 12 hour clock. There is also DateTime.Now.ToString("t") and DateTime.Now.ToShortTimeString(), the latter just turns around and executes the former. These last two are locale/culture aware. Regards
Thanks Neil that worked great. Just a note to all that read this. When you use
DateTime.Now.ToString("HH:mm");
your results will be in military time. However a simple change toDateTime.Now.ToString("hh:mm");
will return "regular" time. Thanks again Neil. :) Nick Parker