I would like to write some information to log files. First I want to write down the date, then the time and after that the log message. An example would be
11.02.2019 | 09:36:24 | Something finished
Currently I get logged this
11.02.2019 00:00:00 | 09:36:24 | ...
11.02.2019 00:00:00 | 09:36:24 | ...
11.02.2019 00:00:00 | 09:36:24 | ...
I use this code for the date and time handling
private string GetDateTimestamp()
{
string currentDate = DateTime.Now.Date.ToString();
string currentTime = DateTime.Now.ToLongTimeString();
return $"{currentDate} | {currentTime} | ";
}
How can I remove the trailing zeros from the date when using c# DateTime.Now.Date
?