Search code examples
c#datetimeunhandled-exception

string was not recognized as a valid Datetime on Windows Server 2016


i created an app that uses DateTime.ParseExact in the following way:

DateTime.ParseExact(extractedFileDate, "ddd MMM dd HH:mm:ss yyyy", CultureInfo.CurrentCulture, System.Globalization.DateTimeStyles.None);

extractedFileDate is storing a string with a date, for example: "Tue Oct 08 12:07:13 2013"

when i run my app from my computer on Windows 10 everything is running smooth, but when i try to run the same app on Windows Server 2016 i get the "string was not recognized as a valid Datetime" error massage.

the content of the date string is showing just the same value.

what can it be ?

david.


Solution

  • Solution:

    DateTime.ParseExact(extractedFileDate, "ddd MMM dd HH:mm:ss yyyy", CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None);