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;
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/