[RESOLVED] Converting non-US date string to date object
I'm saving a date to a JSON file as a string using Date.Now.ToString & then reading it back in & converting to a date at startup using CDate(myDateStr) which works fine, except when somebody from a non-US country runs my app the date is written as "Thu 15 02 2024 22:38:32" & when I try to convert that string to a date I'm getting an error "String was not recognized as a valid DateTime." How can I make my code handle both a US format ("mm:dd:yy hh:mm:ss") & non-US format "Thu 15 02 2024 22:38:32"? Do I need to specify the format when I write it so it's always saved in a consistant format or is there a better way? Thanks...
Re: Converting non-US date string to date object
IIRC just saving it as a date, without converting to a string, should work.
Re: Converting non-US date string to date object
That's interesting. I didn't know you could do that. So when I don't convert to a string it gets saved as "2024-02-18T12:04:30.5186749-05:00". It looks like it's more of a universal date/time format. So when I read that back in & convert to a date object will it display in the format of the users localization setting?
Re: Converting non-US date string to date object
Once it has been deserialised to a date then it will behave based on the normal date behaviour. It should indeed reflect the user's locale settings.
Re: Converting non-US date string to date object