Created
April 22, 2024 06:54
-
-
Save orion55/f589a8afeec58a88777b7aab777dac45 to your computer and use it in GitHub Desktop.
Преобразование даты в нужной тайм-зоне в зону UTC и формат ISO
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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