Date Script JavaScript

This JavaScript date script allows you to display the current date in any location you choose. It is very similar to the homepage date script and is useful for headers footers and simple date labels.


Script Title: Date Script
Description: Displays the current date in a specified location

Live Example

The current date is displayed below using JavaScript

Loading date

Date script snippet

Paste this where you want the date to appear or target an existing element by ID

<span id="currentDate"></span>

<script>
(function () {
  var now = new Date();
  var dateText = now.toLocaleDateString(undefined, {
    year: "numeric",
    month: "long",
    day: "numeric"
  });

  document.getElementById("currentDate").textContent = dateText;
})();
</script>

FAQ

Yes You can change the options passed to toLocaleDateString or manually build the date using getMonth getDate and getFullYear

No This script sets the date once when the page loads which is ideal for most use cases

No This script uses plain JavaScript and works in all modern browsers