I have 2 lines of code that attempt to place start and end date times in a JavaScript. new Date('<%= DateTime.now.beginning_of_day.to_s %>') is an example. The DateTime.now.beginning_of_day returns the string 2012-08-13T00:00:00-04:00 which JavaScript translates into 8/13/2012 00:00. Perfect. However, DateTime.yesterday.beginning_of_day.to_s returns ‘2012-08-11 20:00:00-04:00’ which JavaScript translates into 8/11/2012 20:00. I don’t want 8pm the day before yesterday. I want midnight yesterday. I’ve tried Date.yesterday, .in_time_zone("Eastern Time (US & Canada)"), .utc and a myriad of other permutations. What do I have to do to get a date in the past that is formatted in the same manner as DateTime.now?
I have 2 lines of code that attempt to place start and end date
Share
Try this: