Reputation: 3
In my program, I need to change the input datetime information from Turkish (d.M.yyyy) language to English (M/dd/yyyy).
When client edits datetime information in Turkish datetime format(For Example: 24.9.2015), i need to convert this information in English datetime format(Like; 9/24/2015).
I'm trying to parse the input, but not convert the correct format that i need, code block as in the following.
DateTime.TryParseExact(InputDate,"d.M.yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out result))
I need the output named "result" in English U.S datetime format. I also tried to change the code as CultureInfo(en-US) but it doesn't work.
Any ideas?
Upvotes: 0
Views: 400
Reputation: 147
In what language are you trying to achieve this?
Assuming it is c#, DateTime does not have a specific format until you try to convert it into a string and you can convert it to US version by specifying the correct format when calling ToString()
string americanFormat = myDate.ToString("MM/dd/yyyy");
Upvotes: 1