Click here to Skip to main content
15,895,667 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear All,

My PC default datetime format is Hijri.

I have created one windows application in c#. Where DateTime.Now is giving me hijri datetime, where as i'm looking for the Gregorian dateTime.

What I have tried:

DateTime dt = DateTime.ToString(new CultrueInfo("en-US"));

I had phased the same problem in Web based application. So, I have added this code in the web.config file, which solved the problem.

<globalization culture="en-US" uiCulture="en-US" />


Can i do this same thing in app.config also?


Please help me guys.


Thanks
Posted
Updated 9-Nov-17 0:50am
Comments
CHill60 8-Nov-17 7:49am    
Why not just try it and see?
Afzaal Ahmad Zeeshan 8-Nov-17 8:45am    
You need to learn how .NET framework parses and converts data from one format to another. It will really much help you in solving these problems; the same problem comes in Double, Int and other formats of data.

Your error message does not relate to that code:
String not recognized as a valid datetime
Means that somewhere, a string is being converted to a DateTime, not converted from a DateTime to a string.

Start with the debugger, and look at the code that generates the exception - the chances are it's something like Convert.ToDateTime, and you need to look at exactly what the string you are trying to convert contains. When you find it, change the code to use DateTime.TryParse or even DateTime.TryParseExact and report or log errors when they occur.

We can't do that for you - the chances are the error comes from a database or similar, and we have no access to that or your other code.
 
Share this answer
 
Hi abdul subhan mohammed

hope this help you
Arabic Calendar Date to English Calendar Date in Windows Form C#[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900