So I’m trying to assign a variable @time to be the first day of the current month in %d-%b-%Y format. So @time today would be “01-Mar-2012”.
At first I tried:
@time = (Date.today << 1).strftime("%d-%b-%Y") but this goes 1 month in the past, so it returns @time as “06-Feb-2012”.
I know I can get the month as a fixnum with @time = Date.today.mon but that doesn’t help me get to “01-Mar-2012” unless I can convert 3 to Mar and use Date.year for the last part of the string.
I tried looking closely through the Date library to find a way to convert a number to the equivalent 3 letter month var, but can’t figure it out.
The first day will always be 01, so unless I misunderstood the question, this should do it: