c# date in format yyyymmdd code example
Example 1: c# format string to date yyyymmdd
DateTime dt = DateTime.ParseExact(dateString, "ddMMyyyy",
CultureInfo.InvariantCulture);
dt.ToString("yyyyMMdd");
Example 2: c# datetime format ymd
Use DateTime.Now.ToString("yyyy-MM-dd h:mm tt");