SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a date that I want to display to the user, and the format should be dynamic and based on the user. If I do this I get a format that doesn't fit every user.

var prettyDate = originalDate.format('dd MMM yyy, hh:ss');

For example, in Sweden we would like it displayed as 2014-03-04 but another country would want it as 4/3 2014 So instead of explicitly writing the format in the code, I want to get the preferred date format for the current user. My idea was that I could maybe use the culture found in _spPageContextInfo, or something in SP.DateTimeUtil, but I can't find anything.

share|improve this question
up vote 3 down vote accepted

Microsoft Ajax library also contains Date.localeFormat Function that formats a date by using the current culture.


var prettyDate = originalDate.localeFormat('dd MMM yyy, hh:ss');
share|improve this answer
But that still means I have to put in a format string and I don't want to do that. What I want is to use the same rendering of the date as used by SharePoint default, for example in a list – stinaq Mar 4 '14 at 9:58
@stinaq did you see the example dateVar.localeFormat(Sys.CultureInfo.CurrentCulture.dateTimeFormat.ShortDatePat‌​tern);? As a last resort perhaps look at – eirikb Mar 4 '14 at 10:15
Now I saw it! Thank you very much! – stinaq Mar 4 '14 at 10:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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