How to use the date-fns-tz.zonedTimeToUtc function in date-fns-tz

To help you get started, we’ve selected a few date-fns-tz examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bcgov / queue-management / appointment-frontend / src / components / appointment / DateSelection.vue View on Github external
selectTimeSlot (slot) {
    // Note - For cross browser, we must use specific date string format below
    // Chrome/FF pass with "2020-05-08 09:00" but Safari fails.
    // Safari needs format from spec, "2020-05-08T09:00-07:00"
    // (safari also needs timezone offset)
    const selectedSlot: AppointmentSlot = {
      // start_time: new Date(`${this.selectedDate}T${slot.start_time}${timezoneOffset()}`).toISOString(),
      // end_time: new Date(`${this.selectedDate}T${slot.end_time}${timezoneOffset()}`).toISOString()
      start_time: zonedTimeToUtc(`${this.selectedDate}T${slot.start_time}`, this.currentOfficeTimezone).toISOString(),
      end_time: zonedTimeToUtc(`${this.selectedDate}T${slot.end_time}`, this.currentOfficeTimezone).toISOString()
    }
    this.setCurrentAppointmentSlot(selectedSlot)
    this.stepNext()
  }
}
github codesandbox / codesandbox-client / packages / app / src / app / pages / Dashboard / Content / SandboxGrid / index.tsx View on Github external
const distanceInWordsToNow = date =>
  formatDistanceToNow(zonedTimeToUtc(date, 'Etc/UTC'));
github eventespresso / event-espresso-core / assets / prototype / application / hooks / useTimeZoneTime.ts View on Github external
const localTimeToUtc: DateFn = (date: Date | string | number): Date => {
		return zonedTimeToUtc(date, config.timezone.name);
	};
github joelshepherd / tabliss / src / plugins / widgets / nba / api.ts View on Github external
function getEstString(date: Date) {
  const dateUTC = zonedTimeToUtc(
    startOfDay(date),
    Intl.DateTimeFormat().resolvedOptions().timeZone,
  );
  const dateEST = utcToZonedTime(dateUTC, 'EST');
  return format(dateEST, 'yyyyMMdd');
}

date-fns-tz

Time zone support for date-fns v2 with the Intl API

MIT
Latest version published 3 months ago

Package Health Score

82 / 100
Full package analysis