[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: best way to get epoch seconds from mysql datetime value

Gabriele Marrone

11/11/2006 4:41:00 PM


On 11/nov/06, at 17:32, shawn bright wrote:

> Hey there all,
>
> if i have a mysql datetime value that looks like this:
> some_time = '2006-05-11 05:14:14'
>
> and i want to get seconds since the unix epoch, how would i go
> about that ?
>
> thanks

$ irb
>> require 'date'
=> true
>> some_time = '2006-05-11 05:14:14'
=> "2006-05-11 05:14:14"
>> time = Time.parse(some_time)
=> Thu May 11 05:14:14 0200 2006
>> time.to_i
=> 1147317254

--
Gabriele Marrone