Skip to content
Loading
  • Nitin Sontakke
    0
    Methods like ToDateTime() or ToString() of DateTime Structure are dependent on the regional settings of the machine and should never be used, because they are likely to go wrong if regional settings of your development machine and that of deployment server is different.
     
    The reson you are getting this error is for the same above reason. There is diff between user input format and machine's regional settings format. 
     
    It is always a good practise to stick to yyyy-MM-dd date format while communicating with computer systems (such as C#, Database, JSON, XML, csv, etc.) and format them only in UI layer as per user's expectation.
    0
  • Nitin Sontakke
    0
    On second thoughts, is there not any date-time picker control you can use?
     
    Much better from user perspective, less error prone and can possibly give you date value in yyyy-MM-dd format which would be less likely to fail in serveral different environments.
    0