DateTime currentDate = DateTime.Now; Console.WriteLine(currentDate);
DateTime currentDate = DateTime.Now; string formattedDate = currentDate.ToString("dddd, MMMM dd, yyyy - h:mm tt"); Console.WriteLine(formattedDate);
string dateString = "2022-03-12 14:31:45"; DateTime parsedDate = DateTime.ParseExact(dateString, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture); Console.WriteLine(parsedDate);This will output the parsed date and time in the default format (e.g. "03/12/2022 2:31:45 PM"). The Date class is part of the System.DateTime library in C#.