1

I have below code to convert date time from text to 12 hours date format, But showing Arabic AM & PM .

How to get the result in English AM/PM format

Code:

string iDate = "02/06/2018 16:58:42";         
DateTime CHECKTIME = Convert.ToDateTime(iDate);
Label1.Text=CHECKTIME.ToString();

Result:

02/06/2018 04:58:42 م 

Expected Result:

02/06/2018 04:58:42 PM 
Sam Bin Ham
  • 429
  • 7
  • 23
  • [Formatting Date and Time for a Specific Culture](https://msdn.microsoft.com/en-us/library/5hh873ya(v=vs.100).aspx) – Renatas M. Jul 25 '18 at 09:38
  • Here u goo https://stackoverflow.com/questions/5798908/how-to-produce-localized-date-string-with-cultureinfo – CorrM Jul 25 '18 at 09:41

1 Answers1

0

Looks like your CurrentCulture is based on some arabic culture and that's why you get م character as a PMDesignator as an output.

You can always specify your format and culture as a parameters in your ToString method by the way to get the result you want.

Label1.Text = CHECKTIME.ToString("dd/MM/yyyy hh:mm:ss tt", CultureInfo.InvariantCulture);
// I assume 02 is day and 06 is month
Soner Gönül
  • 97,193
  • 102
  • 206
  • 364