Thread7 Thread7 - 10 months ago 48
Ruby Question

Converting a date to string representation

I have a date like this: - 7

I tried to convert it into a string:

@last_week = strftime(( - 7), '%Y-%m-%d')

But I get the error
"undefined method `strftime'"
. What am I doing wrong?


You can do it like this:

@last_week = ( - 7).strftime('%Y-%m-%d')