Last active
September 14, 2023 01:23
-
-
Save marcosrjjunior/73a18611c61b8f93e74e5df2e2ac0c91 to your computer and use it in GitHub Desktop.
date-fns timezone to utc
This file contains 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
// zoneName: {country}/{city} | |
export const zoneTimeToUTC = ({ zoneName }) => { | |
const now = new Date('2022-12-06T20:12:46+10:00') | |
const nowTimezone = formatInTimeZone(now, zoneName, 'yyyy-MM-dd HH:mm:ss') | |
return zonedTimeToUtc(nowTimezone, zoneName).toISOString() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment