Ruby / Rails: ¿convertir int a time O obtener tiempo de integer?
Podemos hacer esto:
i = Time.now.to_i
Por ejemplo actual:
i = 1274335854
¿Puedo volver al tiempo?
131
Author: Blair Anderson, 2010-05-20
2 answers
Use Time.at :
t = Time.at(i)
259
Author: Mark Byers,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2010-05-20 06:15:23
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2010-05-20 06:15:23
time.to_i => int
: Devuelve el valor de time como un número entero de segundos desde la época.
Time.at(seconds[, microseconds]) => time:
Crea un nuevo objeto time con el número dado de segundos (y microsegundos opcionales) de epoch.
Enlaces API
23
Author: polygenelubricants,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2010-05-20 06:17:12
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2010-05-20 06:17:12