Date and Math
ECMAScript 2026
Represent a time and calculate values with built-in JavaScript features.
On this page
Create a Date with an explicit time zone
A Date represents an instant. A string ending in Z specifies UTC, and toISOString() prints UTC. Use a time zone explicitly when formatting the same instant as local date and time for a user.
How to try it Open a browser tab, then open Developer Tools → Console. Type the example or paste it into the Console after reviewing it, then run it. Reload before repeating declarations with the same names.
const opening = new Date("2026-11-23T03:00:00Z");
console.log(opening.toISOString());
const time = new Intl.DateTimeFormat("en-GB", {
timeZone: "Asia/Yangon", hour: "2-digit", minute: "2-digit"
});
console.log(time.format(opening));
What to expect The ISO string shows 03:00 UTC. The same instant formats as 09:30 in Yangon.
Round numbers and choose limits with Math
Math.round() rounds to the nearest integer, with ties toward positive infinity. Math.floor() rounds downward. Math.ceil() rounds upward. Math.min() and Math.max() pick the smallest and largest arguments.
How to try it Open a browser tab, then open Developer Tools → Console. Type the example or paste it into the Console after reviewing it, then run it. Reload before repeating declarations with the same names.
console.log(Math.round(2.6), Math.floor(2.6), Math.ceil(2.6));
console.log(Math.max(1500, 2500, 1800));
What to expect 2.6 rounds to 3, floors to 2, and ceils to 3. The largest price is 2500.