Home > Back-end >  Date-FNS Timezone Abbreviation
Date-FNS Timezone Abbreviation

Time:12-06

How do I convert the Australian Eastern Daylight Time to just AEST? Currently it outputs like 11/11/2022 15:29:25 Australian Eastern Daylight Time. Expected output would be like 11/11/2022 15:29:25 AEDT

import { formatInTimeZone } from 'date-fns-tz'
import auLocale from 'date-fns/locale/en-AU'

formatInTimeZone(
        new Date(value),
        'Australia/Sydney',
        'dd/MM/yyyy HH:mm:ss zzzz',
        { locale: auLocale }
      )

CodePudding user response:

Use zzz for the format of the timezone instead of zzzz.

Sample: 'dd/MM/yyyy HH:mm:ss zzzz'

  • Related