Rocshy Rocshy - 1 year ago 112
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");

Answer Source
String test = DateTime.Now.ToString("dd.MM.yyy");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download