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

171
Views
Mongoose timestamp gives inacurate results

CreatedAt gives the time 3 hours ago. How can i make it display the current time?

The schema:

    import mongoose from 'mongoose';

var articleSchema = new mongoose.Schema({
    title: String,
    text: String,
    link: String,
    description: String,
    imgLink: String,
    source: String,
} , { timestamps: true }
);

articleSchema.index({ createdAt: 1,  expires: '60m', default: Date.now });

var Article = mongoose.model("Article", articleSchema);

export default Article;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You probably getting different time zone from mongoose.

Try installing npm i moment-timezone

And change your Date to the right timezone, here is the docs for that: https://momentjs.com/timezone/docs/#/using-timezones/parsing-in-zone/

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!