Posts

Showing posts from April, 2021

Ruby on Rails Time, Date, DateTime Cheatsheet

Rails has a lot of handy methods built-in that sometimes all you have to do is know it. In consequence, there are an overwhelming methods available to get specific time and/or date. This cheatsheet should provide some practical methods for Time, Date, DateTime that may help you in developing with Rails. I have also included an example output of each method so you don't have to manually enter it in rails console to know what the outcome would be. Here is a brief overview of what methods will be covered in this cheatsheet. Feel free to skip to the methods that you need or scroll around to know what methods there are. Maybe it will help you in the future. Enjoy! Current time and date ( now , current , today ) Specific day ( yesterday , tomorrow ) Specific moment in time ( beginning_of_minute , end_of_minute , beginning_of_hour , end_of_hour ) Specific time of the day ( beginning_of_day , middle_of_day , end_of