views:

40

answers:

1

Hi,

I got the below code which I would like to convert to a string in a specific format. But I can't get it working.

Date.today + warning.notify_time_close.seconds

What I want to do is somethin like this but it doesn't work :)

(Date.today + warning.notify_time_close.seconds).strftime "%d-%m-%Y %H:%M:%S"

I know its simple but just don't know how to do it :)

Thanks in advance!

Kenneth

+1  A: 

This should not be necessary, but as a workaround you could try this:

Time.at(
    Date.today.to_time.to_i + warning.notify_time_close.seconds
).strftime("%d-%m-%Y %H:%M:%S")
captaintokyo
Doesn't work either.. :) Still gets an error: undefined method `strftime' for #<String:0x103629d38>
Twiddr
Well then `warning.notify_time_close.seconds` is a `String` somehow... what happens if you try `warning.notify_time_close.seconds.to_i`?
captaintokyo
Still the same.. Even get the error if i replace warning.notify_time_close with 100.. Its all going on in a feed.rss.builder file - could that be an issue?
Twiddr
This one works: Date.today.to_time.strftime("%d-%m-%Y %H:%M:%S").. But doesn't give me the right result..
Twiddr
I posted a workaround.. not sure why the stuff in the braces get converted to a `String`
captaintokyo
Cheers.. Thanks - it seems to work :)
Twiddr