Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

225
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda