Skip to main content

Getting Simple Calendar to show local date and time

Rails • Asked by Jeff Wolfram
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. 

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.

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. 

Hey Jeff,

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

Thanks


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


Sounds good, thanks for the response.


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 27,623+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.