Picking Date format string from user locale

http://stackoverflow.com/questions/14995882/picking-date-format-string-from-user-locale

by phusick

HTML

<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.8/dijit/themes/claro/claro.css">

CSS

body {
    padding: 30px;
}

JavaScript

require([
    "dojo/i18n",
    "dojo/date/locale"
], function(
    i18n
) {
    
    var packageName = "dojo.cldr";
    var bundleName = "gregorian";
    var localeName = i18n.normalizeLocale(); // optional for the default locale
    
    var bundle = i18n.getLocalization(packageName, bundleName, localeName);
    
    // all available formats
    console.dir(bundle);
    
    // some of them
    console.log(bundle['dateFormat-full']);
    console.log(bundle['dateFormat-long']);
    console.log(bundle['dateFormat-medium']);
    console.log(bundle['dateFormat-short']);
});