Source Code Helpful?
- Using that code you can get dates and times in all languages
- Localization in JavaScript
- Source code is helpful for all browsers (IE, Chrome, Mozilla, Safari, and the App versions, etc)
- In the current example, you can test that code with three types of languages English, French, and German
Examples:
<script>
$(document).ready(function(){
//get current date and time
var dt=new Date();
// for options take json object with different date parameters
dt.toLocaleDateString("en-UK",{weekday:"long",year:"numeric",month:"long"});
// for options take json object with different time parameters
dt.toLocaleDateString("en-UK",{hour:"numeric",minute:"numeric",seconds:"numeric",timeZoneName:"long"});
// for german or french use de-DE or fr-FR at the place of en-UK
});
</script>
Other attributes for date and time parameters:
Use those attributes within JSON object and get different results according to attributes for live example watching video
weekday:
- long
- short
- narrow
year:
- numeric
- 2-digit
month:
- numeric
- 2-digit
- long
- short
- narrow
day:
- numeric
- 2-digit
hours:
- numeric
- 2-digit
minute:
- numeric
- 2-digit
seconds:
- numeric
- 2-digit
timeZoneName:
- long
- short
0 Comments