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 8779395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:46:35+00:00 2026-06-13T19:46:35+00:00

First, does JavaScript have no basic Date comparision the way Python might? In my

  • 0

First, does JavaScript have no basic Date comparision the way Python might?

In my Node.js script, I have the following lines:

console.log(Date(2012,11,10) < Date(2012, 11, 9))
console.log(Date(2012,11,10) > Date(2012, 11, 9))

However, both of these lines return false.

It appears there are tons of questions about “Date Comparison in JavaScript”.

However, for virtually all of them someone responds with their home-made solution for comparing dates, some of them quite long and/or “hacky”.

Is there really no inherent or idiomatic way to simply compare dates in JavaScript.
Do any Node libraries support it?

  • 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-13T19:46:37+00:00Added an answer on June 13, 2026 at 7:46 pm

    You need to use the new keyword

    console.log(new Date(2012,11,10) < new Date(2012, 11, 9))
    console.log(new Date(2012,11,10) > new Date(2012, 11, 9))
    

    As Elias Van Ootegem pointed out it’s a standard to return a string if the new keyword is omitted:

    When Date is called as a function rather than as a constructor, it returns a String representing the current time (UTC).

    NOTE
    The function call Date(…) is not equivalent to the object creation expression new Date(…) with the same arguments.

    Source: 15.9.2 The Date Constructor Called as a Function

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

Sidebar

Related Questions

Possible Duplicate: Why does javascript replace only first instance when using replace? I have
I have the following basic javascript function that I call when an onClick event
Does the following code contain a memory leak of the first three characters in
I have a CMS generating a basic navigation using a UL. Each first-level LI
Since Javascript does not have any functionality by itself to communicate over raw sockets
I have Javascript code that does this: var oObjchbox = document.getElementById(CheckBox_ + countyId); The
I have a basic typing tutor built in javascript. It has two portions: The
I m very new to Node.js and Socket.io. I have built a very basic
Does JavaScript have a sort of event listeners? My scenario: I want to execute
I have a very basic JavaScript question. I am writing a program which will

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.