-1

There are many threads on retrieving pacific time from servers but i want to convert it into the local time like IST.

I am living in India.

Preferably I want to use firebase for retrieving time. If you can provide me with code that retrieves time from Firebase and converts it into the local time and date, I will be very thankful.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

2 Answers2

1
  1. You have to get time from server, They are lot of services but I prefer to use this one which gives you all data you need in UTC timezone: https://script.google.com/macros/s/AKfycbyd5AcbAnWi2Yn0xhFRbyzS4qMq1VucMVgVvhul5XqS9HkAyJY/exec (from http://davidayala.eu/current-time)
  2. Then You have to Parse the service response and Get the Values you need.
  3. Finally Instantiate Calendar and Set it with the value you got (day, week, month) and get the time in the timezone you want with the format you want ^^

P.S: You can also get the time in any timezone (It support many local time in India too) from the above API without any need for conversion.

Keivan Esbati
  • 3,376
  • 1
  • 22
  • 36
0
  1. get the time (time milliseconds) from internet server .(You can attach it response from the server ).
  2. get the zone of the internet server let it be +2:45 ( also attach it in response from server ) and convert it to milliseconds.

  3. get the timezone (+6:00) from your device and convert it to milliseconds.

4.now to the time milliseconds from the server add the following (time milliseconds from server +your timezone milliseconds - server timezone milliseconds

  1. now convert result to your desired time date format
erluxman
  • 18,155
  • 20
  • 92
  • 126
  • @AbhinavMarwaha at least do Google and also thank person for providing answer with details. – Paresh Mayani Mar 08 '17 at 05:05
  • Sorry for that i will google it and i am still learning from all the great developers out there . Thank you for your help . I am still wondering why my question is downvoted atleast provide me with reason so that i can improve. Thank you once again.@PareshMayani –  Mar 08 '17 at 05:13