Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

222
Vistas
How to add time to the CURRENT_TIMESTAMP on knex.js?

I have such knex statement:

return knex(table).insert({
            id: uuid.v4(),
            ...data,
            created_at: knex.raw('CURRENT_TIMESTAMP'),
            updated_at: knex.raw('CURRENT_TIMESTAMP'),
            expired_at: ...
        })

There are 3 timestamp fields created_at, updated_at and expired_at. There is no problem with 2 first, but I have no idea, how to add expired_at like +1 minute.

On pseudocode I would look like:

expired_at: knex.raw('CURRENT_TIMESTAMP + 1 minute')

So, how can I add time using CURRENT_TIMESTAMP?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

you can use knex.fn.now() to execute CURRENT_TIMESTAMP function on the database and you will need to use mysql built in methods to calculate your future date

have a look on mysql date functions in the offical doc

for example:

knex.raw('SELECT date_add(?, INTERVAL ? day)', [knex.fn.now(), 1])
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda