Constructor
DateTime date1 = new DateTime(2010, 8, 18, 16, 32, 0);
Console.WriteLine(date1.ToString());
// The example displays the following output, in this case for en-us culture:
// 8/18/2010 4:32:00 PM
https://docs.microsoft.com/en-us/dotnet/api/system.datetime.-ctor?view=netcore-3.1
ToString() method
In this example I use DateTime.Now.ToString(“yyyyMMdd_HHmmss”) in order to create a dated file Name that will look like this:
20200610091524_myText.txt
string folder = Environment.SpecialFolder.MyDocuments;
string currentDate = DateTime.Now.ToString("yyyyMMdd_HHmmss");
string fileName = Path.Combine(folder, $"{currentDate}_myText.txt");
https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings