native-dates

Examples / Time zones

A meeting across zones

Pick a meeting time tomorrow in your local zone and view that exact moment across cities around the world.

Try this

  1. Set the start time to 23:00 to watch Tokyo and Kolkata cross into the next weekday.
  2. Switch the preview bar to another time zone so the meeting is scheduled from that city instead.
  3. Add 'Australia/Sydney' to CITIES in cities.js to append another city to the schedule.
import { tomorrow } from 'native-dates';

import { CITIES } from './cities.js';

const input = document.querySelector('input');
const summary = document.querySelector('#summary');
const list = document.querySelector('ul');

function render() {
  const meeting = tomorrow().at(input.value);
  summary.textContent = meeting.format('full');

  list.innerHTML = CITIES.map((zone) => {
    const there = meeting.in(zone);
    const sameDay = there.date.equals(meeting.date);
    return `<li>
      <code>${zone}</code>
      <b>${there.format('time')}</b>
      <span class="muted">${sameDay ? '' : there.format({ weekday: 'long' })}</span>
    </li>`;
  }).join('');
}

input.addEventListener('input', render);
render();

Starting…

How it works

Scheduling starts with tomorrow().at(input.value), pairing tomorrow’s calendar day with the chosen clock time. That single moment drives the whole list without manual UTC offsets.

For every city, meeting.in(zone) views the same instant in that IANA time zone and format('time') prints its local clock.

Comparing there.date against the host’s date detects when a city has crossed midnight. The row shows a weekday label only when the day differs.