Rocshy Rocshy - 2 months ago 24
C# Question

Current date without time

How can I get the current date but without the time? I am trying to convert the date from the "" format to "yyyy-MM-dd", because

returns the time too, I get an error (
String was not recognized as a valid DateTime
.) when I try to do the following.

string test = DateTime.ParseExact(DateTime.Now.ToString(), "dd.MM.yyyy", CultureInfo.InvariantCulture).ToString("yyyy-MM-dd");

String test = DateTime.Now.ToString("dd.MM.yyy");