The Azure Function app is deployed in Central India region where the default format is dd/MM/yyyy HH:mm:ss. The string to date conversion works as expected in local environment (In India region).
In the live version, the string to date conversion is like "MM/dd/yyyy HH:mm:ss tt". What is the reason for this behaviour?
string dateString = "25/12/2020 10:55:58";
DateTime date = DateTime.ParseExact(dateString, "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture);
dateString = date.ToString();
// In Local: 25-12-2020 10:55:58
// In live: 12-25-2020 10:55:58 AM
CodePudding user response:
It looks like it's parsing them the same, but outputting them incorrectly. Try specifying a format in your ToString() function.
The reason for this is that the default output format (when not explicitly specified) is based on the machine it's running on. Your live machine is probably set to non-Indian date formats.