0

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?

1 Answers1

1

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");
Berkay Dincer
  • 112
  • 1
  • 10
  • Berkay, thanks for your help. I've got rid of this problem with your comments. I'm using Turkish format right now. But with this command, if the users language datetime format will be also in ("en-US"), i can also change it and this will works. DateTime.Parse(myDate,new CultureInfo("tr-TR"),DateTimeStyles.AssumeLocal)).ToString("MM/dd/yyyy"); – Serkan Çolak Sep 08 '15 at 06:56