1

I need date format of site, I can get date separator using get_regionalSettings() and get_dateSeparator() .

I tried get_dateFormat() but it returns "1".

I need to know date format of particular site "dd/mm/yyyy" , "mm/dd/yyyy" or whatever the default date time format is set in SharePoint site.

How can I get that using JSOM?

  • I'm not sure actually, never used _api/web/RegionalSettings/dateFormat. But it return 0 from webs with locale US (mmddyyyy)and 1 from my web with Norwegian (ddmmyyyy). You could check if 1 is ddmmyyyy and vice versa. – Anders Aune Sep 21 '17 at 7:10
  • @AndersAune I think there are more formats than ddmmyyyy and mmddyyy, so it won't work, and also what about date separators? – codemirror Sep 22 '17 at 5:46
1

The first step is to figure out what time zone it is displaying. There are two types of Regional Settings that specify the time zone:

  • Regional Settings in User Profile Settings
  • Regional Settings under each site

May b try this link How to Get the Time Zone in SharePoint Online Using JSOM

-1

Add a reference to moment js. This can be downloaded from https://momentjs.com/downloads/moment.js .

And add below code in your client context code.

 var dt = oListItem.get_item('datelistcolumnname');if (dt != null) { alert(moment(dt).format('L')); }
  • I want to get the date format of particular site, are you sure you are answering my question. – codemirror Sep 20 '17 at 16:37

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.