-1

I want to convert UTC time to local Time Zone where Time Zone will be dyanamic. The question is asked because I want my UTC date to get converted automatically using DayLightSaving Time. DayLightSaving for Adelaide on 2019-04-25 is +4 hours and standard is +5. This +1 hour or -1 hour should be calculated automatically. I hava gone through all stackoverflow similar questions but could not find or relate well. so how to convert UTC date into DST date ? momemt.js can be used but plz avoid giving links in your answer. I would prefer actual function to convert dates. Here is the actual problem,

`Current Date = 2019-04-25   --yyyy-mm-dd
TimeZone = Adelaide
MyUTCDate = 2019-04-25 8:30:00
ConvertedDSTTime = ?`
Akki
  • 61
  • 1
  • 2
  • 10
  • It is unclear what you are asking for. Are you looking for a solution that uses Moment.js? Or are you looking for a solution that does not require a library? Also, what form of input does your data come in, and what form of output are you looking for? Can you provide an example in actual JavaScript code? – Matt Johnson-Pint Nov 28 '18 at 18:40

1 Answers1

2

It is unclear from your question, but perhaps you are looking for something like this?

new Date('2019-04-25T08:30:00Z').toLocaleString('en-AU', {timeZone: 'Australia/Adelaide'})
//=> "25/04/2019, 6:00:00 pm"
Matt Johnson-Pint
  • 230,703
  • 74
  • 448
  • 575