Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9077711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:26:22+00:00 2026-06-16T19:26:22+00:00

I generate a date in MongoDB shell: var d = new Date(); d but

  • 0

I generate a date in MongoDB shell:

var d = new Date();
d

but the date result doesn’t match the time in my location

However, the same code in javascript, the console.log(d) can output the correct time in my location

Why? How can I generate my local time in MongoDB?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T19:26:23+00:00Added an answer on June 16, 2026 at 7:26 pm

    MongoDB (including the console) will by default always generate and stores in UTC, however ISODates do support a timezone offset ( http://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC ) however you would need to manage the creation of that offset from your application.

    As @CRUSADER mentions it is normally better to store the users offset within the row or even not at all, particularly if your user could be accessing from many locations with many different timezones. In this case it might actually be better to modify the dates within your client JavaScript to take care of the difference in timezone from where they are currently accessing the page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to generate current date and time in a format like this Mon,
I attempted to generate the date range between date x and date y but
I have this code, it should generate a random date every button pressed and
I want to know how to generate time and date in C# then format
I need to generate a new Date object for credit card expiration date, I
I need to generate a random Date. I do not need time in my
I'm trying to generate a date string from current time to put into HTTP
I need to generate records on given start-date, end-date and time frequency(Weekly, Monthly etc.)
I have a date time that I generate like this: DateTime myDateTime = DateTime.Now;
Based on current date and time, can i generate 6 digit number? One person

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.