Ask A Question

Notifications

You’re not receiving notifications from this thread.

Getting Simple Calendar to show local date and time

Jeff Wolfram asked in Rails
I have been using your Simple Calendar gem and it is all working great. The only problem is I can not figure out how to fix the date and time so it will show everything in local date and time. Right now, I am in California and it switched the date at 4pm on the month calendar. I know that is because the server is a time that is 8 hours ahead. Where should I make the changes in the calendar to display the time and date correctly? Any help would be much appreciated. 
Reply
Hey Jeff,

You want to either use the local_time gem to handle this client side or simply set the Time.zone to the user's timezone for every request. 

For the second option, you have to save the timezone on their database record so you can retrieve it and set it every time. 

local_time's a lot simpler as it just checks the browser's timezone and converts all the times using JS.
Reply
Thanks for the super speedy response Chris. Before I wrote you, I changed the time zone in my app and also on the heroku server. The weird thing is it took all my existing date entries and moved them one day forward but when you pull the data entry up and check the date, it is still set for the next day. When you look to see what date the calendar says, that is correct. It was just all the data that moved. 
I want to try this gem but I am just confused on how to configure it with the simple_calendar month view. 
Reply

Hey Jeff,

I'm having the same issues with the calendar moving the current date a day forward.
Did you figure this out?

Thanks

Reply

I just wrote a migration that went though the dates and changed them to the day before.

Reply

Sounds good, thanks for the response.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,329+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

    © 2024 GoRails, LLC. All rights reserved.