2

Okay, so I have been struggling with this problem for to many hours now. What I want to do is to convert "Brasilia Time (BRT) -0300 UTC" into user's local timezone. How can I do this using javascript? I've also tried some javascript libraries like moment.js but still no luck.

someother
  • 21
  • 1
  • 3
  • See this question for an idea: http://stackoverflow.com/questions/1091372/getting-the-clients-timezone-in-javascript – Bluefire Jun 21 '14 at 15:34
  • 1
    Incidentally, the wording in your question makes no sense: there is no such thing as a "UTC timezone", UTC *is* a timezone. What you have there is a timezone string which includes the relevant offset from UTC. – IMSoP Jun 21 '14 at 15:45
  • Well, yeah, I should have said UTC offset +300. But still, how can I do it? – someother Jun 21 '14 at 16:21
  • possible duplicate of [How to initialize javascript date to a particular timezone](http://stackoverflow.com/questions/15141762/how-to-initialize-javascript-date-to-a-particular-timezone) – Matt Johnson-Pint Jun 21 '14 at 19:24
  • See the dup link, and consider using moment-timezone with the `"America/Sao_Paulo"` time zone. If you need more help than that, you'll have to show some code. See [How to create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) in the help center. – Matt Johnson-Pint Jun 21 '14 at 19:25
  • 1
    how did you use moment.js? can you provide some code? I am sure it is possible with MomentJs library – BomberMan Oct 17 '14 at 12:26

1 Answers1

0

You do time.clone().tz('Yourlocalzone'). See also: http://momentjs.com/timezone/ for full documentation.

Lennart Regebro
  • 167,292
  • 41
  • 224
  • 251