Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

224
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!