Skip to content

Instantly share code, notes, and snippets.

@marcosrjjunior
Last active September 14, 2023 01:23
Show Gist options
  • Save marcosrjjunior/73a18611c61b8f93e74e5df2e2ac0c91 to your computer and use it in GitHub Desktop.
Save marcosrjjunior/73a18611c61b8f93e74e5df2e2ac0c91 to your computer and use it in GitHub Desktop.
date-fns timezone to utc
// 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