List of Time methods

There are low of methods available on Time.now. Here it is exclusively for you :-

  • To find a current time and date – t=Time.now
  • To find the beginning of the day – t.at_beginning_of_day (or) t.at_mid_night
  • To find the beginning of the month  – t.at_beginning_of_month
  • To find the beginning of the quarter – t.at_beginning_of_quarter
  • To find the beginning of the week – t.at_beginning_of_week (or) t.monday
  • To find the beginning of the year – t.at_beginning_of_year
  • To find end of the month – t.at_end_of_month
  • To find end of the year – t.at_end_of_year
  • To find end of the quarter – t.at_end_of_quarter
  • To find end of the week – t.at_end_of_week
  • t.since(seconds) or t.in(seconds) will give you the time, which was after no of ‘seconds’ you give from the current time.
  • t.months_ago(months) will give you the date, exactly before the no of ‘months’ you give.
  • t.since(months) (or) t.next_month will give you the date, exactly after the no of ‘months’ you give.
  • t.next_week will get you the date of next week, same day
  • t.next_year will get you the date of next year, same day, same month.
  • t.past? will tell whether the date and time (t) is available on past.
  • t.future? will tell whether the date and time (t) is available on future.
  • t.today? will tell whether the date (t) is today
  • t.tomorrow will tell the time of tomorrow, from the object (t)
  • t.yesterday will tell the time of yesterday, from the object (t)
  • t.years_ago(years) will give the date of past, from the no of ‘years’ you give.
  • t.years_since(years) will give the date of future, from the current day to the no of ‘years’ you give.