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

  • Home
  • SEARCH
  • 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 640823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:59:44+00:00 2026-05-13T20:59:44+00:00

I get two strings formated like (Brazilian Format): DD/MM/YYYY, I need to compare both.

  • 0

I get two strings formated like (Brazilian Format): “DD/MM/YYYY”, I need to compare both. Since the first field is the begin and the last is the end,

My validation is begin <= end

Date.new(begin) is generating ‘invalid date’ even on ISO !

  • 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-05-13T20:59:44+00:00Added an answer on May 13, 2026 at 8:59 pm

    Don’t use Date.new. Use new Date(). Because of the format of your date string, I would recommend grabbing each field individually and passing them into the constructor:

    var startYear = parseInt(document.getElementById('startYear'), 10);
    var startMonth = parseInt(document.getElementById('startMonth'), 10) - 1; // as per Residuum's comment
    var startDay = parseInt(document.getElementById('startDay'), 10);
    var start = new Date(startYear, startMonth, startDay);
    

    etc. If you’re handed a date string, then you can use fuzzy lollipop’s method to get each field from the string. I’m not sure if the Date constructor will accept unparsed strings for the individual fields, however.

    The, once you have the two dates you’d like to compare, just compare their values in milliseconds since the epoch:

    function isValid(start, end) {
        return start.getTime() < end.getTime();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get a case-insensitive search with two strings in JavaScript working. Normally
I cannot get a two-way bind in WPF to work. I have a string
How do you get two unrelated controls to raise the same custom event? All
I must get two different client application talk without any kind of broker or
For the following header I get the same two errors on all my sitemaps.
While designing an interface for a class I normally get caught in two minds
Two Questions: Will I get different sequences of numbers for every seed I put
I have two SQL scripts which get called within a loop that accept a
When merging two code branches in Team Foundation Server I get the following error:
How do you get the logical xor of two variables in Python? For example,

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.