Converting date and time to a string in C#
Forums:
var now = DateTime.Now;
var shortStyle = string.Format("{0:d} {0:t}", now);
//shortStyle is "6/22/15, 4:10 PM"
var customStyle = now.ToString("yyyy-MM-dd");
//customStyle is "2015-06-22"
- Log in to post comments