DateTime now = DateTime.Now; string formattedDate = now.ToString("yyyy-MM-dd HH:mm:ss"); Console.WriteLine(formattedDate);