Source Code Helpful?
- Using that code you can get date and time in all languages
- Localization in JavaScript
- Source code is helpful for all browsers (IE, Chrome, Mozilla, Safari, and the App versions etc)
- In current example you can test that code with three type of languages like 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>
Live video examples:
Other attributes for date and time parameters:
Use that attributes within JSon object and get different results according to attributes for live example watch 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:
Post a Comment