thnx in advance... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thnx. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
>> Time.now=> Mon Mar 17 13:51:00 -0700 2008>> Time.now.to_i=> 1205787064>> Time.at(Time.now.to_i)=> Mon Mar 17 13:51:18 -0700 2008 On Mon, 17 Mar 2008, shaish wrote:> > thnx in advance...--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
but if I already have a DateTime object how do I turn that object into unix time ? thnx again --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
>> a = DateTime.now >> a. ?? (what method ?)=> 12345678 (unix time) On Mar 17, 10:51 pm, Philip Hallstrom <phi...-LSG90OXdqQE@public.gmane.org> wrote:> >> Time.now > > => Mon Mar 17 13:51:00 -0700 2008>> Time.now.to_i > => 1205787064 > >> Time.at(Time.now.to_i) > > => Mon Mar 17 13:51:18 -0700 2008 > > > > On Mon, 17 Mar 2008, shaish wrote: > > > thnx in advance...- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
>>> a = DateTime.now >>> a. ?? (what method ?) > => 12345678 (unix time)>> d = DateTime.now=> #<DateTime: 106036277450423033/43200000000,-7/24,2299161>>> d.to_s=> "2008-03-17T16:01:40-07:00">> d.to_time.to_i=> 1205794900>> Time.at(d.to_time.to_i)=> Mon Mar 17 16:01:40 -0700 2008> > On Mar 17, 10:51 pm, Philip Hallstrom <phi...-LSG90OXdqQE@public.gmane.org> wrote: >>>> Time.now >> >> => Mon Mar 17 13:51:00 -0700 2008>> Time.now.to_i >> => 1205787064 >>>> Time.at(Time.now.to_i) >> >> => Mon Mar 17 13:51:18 -0700 2008 >> >> >> >> On Mon, 17 Mar 2008, shaish wrote: >> >>> thnx in advance...- Hide quoted text - >> >> - Show quoted text - > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I found this: a = DateTime.now Time.parse(a.to_s).to_i but I''m pretty sure theres a better way to do it... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
weird: ''udefined method to_time fo #<DateTime...'' ? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Are you using rails? Or just ruby? Everything I pasted in works for ruby 1.8.6, rails 1.2.5 via ./script/console. On Mon, 17 Mar 2008, shaish wrote:> > weird: ''udefined method to_time fo #<DateTime...'' > ? > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
before I tried with ruby (via irb). now I tried it via the rails console I do this:>> d = DateTime.now=> #<DateTime: 106036277450423033/43200000000,-7/24,2299161>>> d.to_s=> "2008-03-17T16:01:40-07:00">> d.to_time.to_iand now it claims - ''undefined method ''to_i'' for datetime...'' ruby 1.8.6 rails 2.0.2 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> before I tried with ruby (via irb). > now I tried it via the rails console I do this: >>> d = DateTime.now > => #<DateTime: 106036277450423033/43200000000,-7/24,2299161> >>> d.to_s > => "2008-03-17T16:01:40-07:00" >>> d.to_time.to_i > > and now it claims - ''undefined method ''to_i'' for datetime...'' > ruby 1.8.6 > rails 2.0.2You''re doing something wrong... or something isn''t configured right... $ ./script/console Loading development environment (Rails 2.0.2)>> DateTime.now.to_time.to_i=> 1205797564 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I believe u that it works for u, I mean, why wouldnt it ? the question is why the hell will it not work for me... the ''to_time'' function returns a DateTime object and DateTime really doesnt have a to_i method... I guess the question is why to_time returns a DateTime and not a Time object --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
shaish wrote:> I believe u that it works for u, I mean, why wouldnt it ? > the question is why the hell will it not work for me... > > the ''to_time'' function returns a DateTime object and DateTime really > doesnt have a to_i method... > I guess the question is why to_time returns a DateTime and not a Time > objectplease enter the following:> ENV[''RAILS_ENV'']what do you get? I think the problem is that you are using irb instead of script/console.. hth ilan -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---