Is strftime (hour) showing wrong time?
- by ander163
I'm using this line to get the beginning time of the first day of the month.
t = Time.now.to_date.beginning_of_month.beginning_of_day
When i display this using t.strftime("%A %b %e @ %l:%m %p")
it shows:
Monday Feb 1 @ 12:02 AM
The hour is always 12 (instead of 00), and more wierd the minute changes to match the month in integers. For the February date, it shows 12:02 AM
I use .prior_month and .next_month on the variable to move forward or backwards in time.
So when I move to June, this would display as
Tuesday June 1 @ 12:06 AM
But when I just show the value of "t" using a straight t.to_s, I get this time of 00:00:00, which is what I expect:
Mon Feb 01 00:00:00 -0700 2010
A similar error occurs using end_of_day, but the hour is always 11 PM
and the minute is the same integer value that matches the month in integers, i.e
the time is 11:06 PM in June, 11:02 PM in February.
Qurky?
Admittedly a noob to Rails.
Thanks for any comments or explanations.