Robert Klemme
1/6/2009 4:16:00 PM
On 06.01.2009 16:09, Mmcolli00 Mom wrote:
> How can I add 10 minutes to this time stamp? Thanks. MC
>
> ServerTime = 'Wed Dec 09 16:05:00 -0600 2009'
Here ServerTime is a String and hence cannot do any time related
calculations. You probably rather want
require 'date'
irb(main):017:0> server_time = DateTime.parse 'Wed Dec 09 16:05:00 -0600
2009'
=> #<DateTime: 707090521/288,-1/4,2299161>
irb(main):018:0> server_time.to_s
=> "2009-12-09T16:05:00-06:00"
Now you can add 10 minutes:
irb(main):019:0> (server_time + 10.0 / 24 / 60).to_s
=> "2009-12-09T16:15:00-06:00"
> ServerTime + Time.parse(10)
>
> #<-it does not work without parse since I get error can't convert Fixnum
> into a string. what do you think?
Well, what do *you* think? What does the error message tell you? What
do you conclude from that?
Cheers
robert
--
remember.guy do |as, often| as.you_can - without end