I'm trying to convert datetime format to MM/dd/yyyy but I get result as "05/14/14" which I'm expecting to be "05/14/2014".
What's wrong in this code?
string input = Datetime.Now.ToString("MM/dd/yyyy");
DateTime d;
if (DateTime.TryParseExact(input, "MM/dd/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out d))
{
// use d
}
Update I had short date setting in my pc to "MM/dd/yy" when I changed to "MM/dd/yyyy", it worked. What could be the solution so that datetime should show regardless of pc setting.