How do I.. get a value for time at 9:00am local, regardless of the timezone?
Posted
by ander163
on Stack Overflow
See other posts from Stack Overflow
or by ander163
Published on 2010-04-08T02:23:06Z
Indexed on
2010/04/08
2:33 UTC
Read the original article
Hit count: 417
In my app, I need to set a variable for a start time to be 9:00 a.m. local, wherever the user is located.
I have a timezone variable for each user and the save and retrieve are all working. But I need to set a variable when I create a new event to be 9:00 am in the user's local time zone.
My current method uses the local time of the server, then makes the adjustments for the individual user's time zone. I don't know what I don't know - is there a command to create the value for "Today's date at 9:00 am where you are"?
My current code is:
t = Time.now.to_date.beginning_of_day + 11.hours
(forcing the 2 hour offset between my primary user and the server in a different timezone).
© Stack Overflow or respective owner