Formats a time as a string in the form "H:mm(:ss)" ie: 9:45:04 with optional seconds.
public static string FormatTime(this DateTime dt,
bool showSec = true)
public static string FormatTime(this DateTime? dt,
bool showSec = true)
DateTime or DateTime? value to convert into the string format "H:mm(:ss)".
Optionally removes the seconds from the display to show only minutes in the format "H:mm" ie: 9:45.
string now = DateTime.Now.FormatDateTime();