Home rails- convert time to utc based on browser time zone and start_date
Reply: 1

rails- convert time to utc based on browser time zone and start_date

DevMasterAryan
1#
DevMasterAryan Published in 2017-12-04 17:10:10Z

I have browser time zone in a cookie variable and date in start_date variable as string . say cookie['browser_zone']="Asia/kolkata" & start_date = "2017/12/31 03:00:00" how can I convert above date to with this time zone to UTC time zone.

patkoperwas
2#
patkoperwas Reply to 2017-12-04 18:19:03Z

Use ActiveSupport::TimeZone to parse the time into the correct time zone, then convert it to UTC

ActiveSupport::TimeZone["Asia/Kolkata"].parse("2017/12/31 03:00:00").utc
=> 2017-12-30 21:30:00 UTC
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.330659 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO