bhylu.com

Advertisements

Temporal PlainTime

PlainTime stores a wall-clock time without a date. It suits a recurring opening time.

Where to run this

This example uses the JavaScript console playground. Select Run to execute it; the example does not run on this lesson page.

A practical example

JavaScript

if (typeof Temporal === "undefined") {
  console.log("Temporal is not available in this runtime. Use a supporting browser or a reviewed local polyfill.");
} else {
  const opening = Temporal.PlainTime.from("10:30");
  console.log(opening.add({minutes: 45}).toString());
}

What happens

The time becomes 11:15.