Skip to main content
Ask A Question
You’re not receiving notifications from this thread.

Is there an easy way to display open or closed based on time of day?

General • Asked by Stefan Sanchez

So, I am making an application that is listing multiple businesses. I am wanting to have a label that displays open or closed for each individual business. Could anyone give me guidance on how to make this possible? I am hoping to store the function within a model, so that it can be stored with the rest of the business information. Thanks!

Hey Stefan,

So my advice with storing this stuff in the model is only to do it if you'll need it for queries. I think that'll be important (filtering by businesses that are open) so it makes sense to be there. Do you have a data format for saving the hours the places are open? Will they always be a consistently open chunk of time like 9-5? I imagine days and weekends will have different hours too. Do you need to handle that as well?

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 30,005+ 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.