Header Ads Widget

Responsive Advertisement

Get date and time in different languages in JavaScript (localization)



Source Code Helpful?

  1. Using that code you can get dates and times in all languages
  2. Localization in JavaScript
  3. Source code is helpful for all browsers (IE, Chrome, Mozilla, Safari, and the App versions, etc)
  4. 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

Post a Comment

0 Comments