x
 
1
<!DOCTYPE html>
2
<title>My Example</title>
3
4
5
<time id="msg"></time>
6
7
<script>
8
  // Create a JavaScript Date object for the current date and time, and set the desired options.
9
  var date = new Date(),
10
      options = { weekday: "long", month: "long", day: "numeric", year: "numeric" };
11
 
12
  // Convert to locale string and add a locale and the options
13
  date = date.toLocaleString( "en-US", options );
14
 
15
  // Output the date to the above HTML element
16
  document.getElementById("msg").innerHTML = date;
17
</script>