“Rails convierte la marca de tiempo de Unix a DateTime” Código de respuesta

UNIX TimeStamp Rails hasta la fecha

2.1.0 :002 > Time.at(1432927800000/1000).to_s(:db)
 => "2015-05-29 22:30:00"
# Instead of strftime will be better to use predefined :db pattern from ActiveSupport:

TalaatMagdy

Rails convierte la marca de tiempo de Unix a DateTime

## Timestapms without leading zeros won't require the division by a thousand.
## If you do that you'll get 1970 as the date
## So instaed just run this

Time.at(1652276037)

 => "2022-05-11 13:33:57 +0000"

## From there just format as you wish to using :db or strftime
Benedict Ouma

Respuestas similares a “Rails convierte la marca de tiempo de Unix a DateTime”

Preguntas similares a “Rails convierte la marca de tiempo de Unix a DateTime”

Más respuestas relacionadas con “Rails convierte la marca de tiempo de Unix a DateTime” en Ruby

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código