I don't know of a way to do that (you can get the language and try to deduct the locale from that).
I tried to cook a little something to try and do that (only tested on Firefox with one locale). should work as long as the short date string includes the date as digits, so it might fail for, say, arabic. It might have other bugs too, i don't know all the different locales peculiarities, this is just a concept...
function getShortDateFormat() {
var d = new Date(1992, 0, 7);
var s = d.toLocaleDateString();
function formatReplacer(str) {
var num = parseInt(str);
switch (num % 100) {
case 92:
return str.replace(/.{1}/g, "Y");
case 1:
return str.length == 1 ? "mM" : "MM"
case 7:
return str.length == 1 ? "dD" : "DD"
}
}
shortDateFormat = s.replace(/\d+/g, formatReplacer);
return shortDateFormat;
}
getShortDateFormat();
The outputted format will be:
- Y: the number of digits to represent years
- dD = short day (i.e. use only one digit when possible)
- DD = long day format (i.e. two digits always)
- mM/MM - same for months
So in my browser, the shortDateformat you get is "MM/DD/YYYY".