How to convert date format

I have “Friday, April 02, 2010” as the date when I want to display “04/02/2010” if the browser language is English and “02.04.2010” if the browser language is selected as German. All I want is to show the date according to the format of the browser.

Any idea how this can be done?

+1
source share
2 answers

Difficult pretty fast, it's best to find a library to do this.

DateJS, , 150 , , , . , , - , ISO 8601 ( ), .

+2
<html>
<body>
hi
<script>
var lang = navigator.language;
if (!lang) {
lang = navigator.userLanguage;
}
alert (lang);
if (lang.match (/^en/)) {
document.write ("04/02/2010");
} else if (lang.match (/^de/)) {
document.write ("02.04.2010");
} else {
document.write ("I give up");
}

</script>
</body>
</html>
0

All Articles