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
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
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’
=> truesome_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 2006time.to_i
=> 1147317254
On Sun, 12 Nov 2006, 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
require ‘time’
t = Time.parse some_time
epoch_seconds = t.to_i
-a
Hey great ! thanks, this works for me.
sk
i suppose i could use that, i am working with mysql 5 ( oh, the luxury )
i am just not that knowledgeable with it.
thanks
Hi,
On Son 12.11.2006 01: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 ?
If you have the possibility to use mysql why not to use the builtin
function:
UNIX_TIMESTAMP(date)
from http://www.mysql.org/doc/refman/4.1/en/date-and-time-functions.html
Due the fact that I don’t know which version of mysql you use I have
looked into the lowest possible version
Hth
Aleks
On Son 12.11.2006 03:12, shawn bright wrote:
i suppose i could use that, i am working with mysql 5 ( oh, the luxury)
i am just not that knowledgeable with it.
http://www.mysql.org/doc/refman/5.0/en/date-and-time-functions.html
Same there => UNIX_TIMESTAMP(date)
Hth
Aleks
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs