Skip to content

Instantly share code, notes, and snippets.

@orion55
Created April 22, 2024 06:54
Show Gist options
  • Select an option

  • Save orion55/f589a8afeec58a88777b7aab777dac45 to your computer and use it in GitHub Desktop.

Select an option

Save orion55/f589a8afeec58a88777b7aab777dac45 to your computer and use it in GitHub Desktop.
Преобразование даты в нужной тайм-зоне в зону UTC и формат ISO
export const convertToISO = (date: string, time: string, zone: string): string => {
const [day, month, year] = date.split('.').map(Number);
const [hour, minute] = time.split(':').map(Number);
const dateTime = DateTime.fromObject({ year, month, day, hour, minute }, { zone });
const utcDateTime = dateTime.toUTC();
return utcDateTime.toISO();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment