I need to get three dates in variables
Today Since Midnight which I have as
t = Time.now.strftime(“%Y-%m-%d 00:00:01”) # 2012-11-19 00:00:01
Yesterday Since Midnight (i.e. 00:00:00 to 23:59:59)
y1 = 2012-11-18 00:00:01
y2 = 2012-11-19 23:59:59
it is specifically the y1 & y2 variables I need to create as strings for use in a gem. being new to ruby I am a little confused as Time.yesterday doesn’t seem to do what I need
EDIT
For this be sure to include
require ‘active_support/all’
and ensure the gem is bundled for your application.
Used:
@current = (Time.now).beginning_of_day.utc.strftime("%Y-%m-%d")
@yesterday = (Time.now - 1.day).beginning_of_day.utc.strftime("%Y-%m-%d")
@everything = (Time.now - 2.day).end_of_day.utc.strftime("%Y-%m-%d")
You can do,