Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

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

Packages

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.

Behavior

Save Automatically?

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.

HTML

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

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

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

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

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

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

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

              
            
!

CSS

              
                
              
            
!

JS

              
                import { DateTime } from "https://cdn.skypack.dev/luxon@1.25.0";

// Now
// Notice it uses its own constructor instead of Date
const now = DateTime.local()
// Get the hour from today
const hour = now.hour
// Add 7 days to now
const weekAdd = now.plus({days: 7});

// Now formatted like "Monday, November 23, 5pm"
const dateFormatted = now.toFormat("EEEE',' MMMM d',' ha")

// Date and time on Lord Howe Island
const dateTimeLocale = now.setZone('Australia/Lord_Howe')

//Parsing
const dateTimeParsing1 = DateTime.fromFormat('Jul 8, 2005', 'MMM d, y').toJSDate()
const dateTimeParsing2 = DateTime.fromFormat('2005-07-08', 'y-MM-dd').toJSDate()

document.getElementById("package-link").innerHTML = "Luxon"
document.getElementById("package-link").href = "https://www.skypack.dev/view/luxon"
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;

              
            
!
999px

Console