Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <h1>datetime with <a href="" target="new" id="package-link"></a></h1>
  <h2>Your time = <code>now</code></h2>
  <span id="today"> </span>

  <h2>Get the hour from <code>now</code></h2>
  <span id="today-hour"> </span>

  <h2>Add 7 days to <code>now</code></h2>
  <span id="week-add"> </span>

  <h2><code>now</code> formatted like "Monday, November 23, 5pm"</h2>
  <span id="date-formatted"></span>

  <h2>Date and time on Lord Howe Island</h2>
  <span id="date-time-locale"></span>

  <h2>Parsing <code>Jul 8, 2005</code></h2>
  <span id="date-time-parsing-1"></span>

  <h2>Parsing <code>2005-07-08</code></h2>
  <span id="date-time-parsing-2"></span>





                import dayjs from ""

// Now
// Uses the native JavaScript date
const now = new Date()
// Get the hour from today
const hour = dayjs(now).hour()
// Add 7 days to now
const weekAdd = dayjs(now).add(7, 'day')
// Now formatted like "Monday, November 23, 5pm"
const dateFormatted = dayjs(now).format("dddd, MMMM D, ha");

// Date and time on Lord Howe Island
// I can't get this to work, the time is wrong
/*import utc from ""
import timezone from ""
const dateTimeLocale = dayjs(now).tz("Australia/Lord_Howe") 
const dateTimeLocale = ""

// Parsing
const dateTimeParsing1 = dayjs("Jul 8, 2005 ");
const dateTimeParsing2 = dayjs("2005-07-08");

document.getElementById("package-link").innerHTML = "Day.js"
document.getElementById("package-link").href = ""
document.getElementById('today').innerHTML = now
document.getElementById('today-hour').innerHTML = hour
document.getElementById('week-add').innerHTML = weekAdd
document.getElementById('date-formatted').innerHTML = dateFormatted
document.getElementById('date-time-locale').innerHTML = dateTimeLocale
document.getElementById("date-time-parsing-1").innerHTML = dateTimeParsing1;
document.getElementById("date-time-parsing-2").innerHTML = dateTimeParsing2;