I have a Sharepoint list item with a date field. When I read the value for the item it gives me in format of MM/DD/YYYY. But my local machine is having different DateTime format as DD/MM/YYYY. So while parsing to DateTime either it changes the value or thows exception as Invalid DateTime.

DateTime dt = Convert.ToDateTime(item["DateTime"]);

How can I get the DateTime format for the field?

Thanks in advance.


Please tried to handle null exception for Date. Other wise it work.

if(item["DateTime"]!=null && item["DateTime"]!="")
      DateTime dt = Convert.ToDateTime(item["DateTime"]);
  • That is not the concern. I need DateTime format – Mayuresh Feb 6 '18 at 6:17
  • As you said it's through exception that why I said you handle null exection – Bharat Khunti Feb 6 '18 at 6:25

Finally I got the answer. We can get DateTime Format using Regional Settings property.

ClientContext.Load(f_Web, website => website.RegionalSettings)
var format = f_Web.RegionalSettings.DateFormat;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.