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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:34:22+00:00 2026-06-14T03:34:22+00:00

I am comparing two dates in javascript function checkCurrentDate(expiryDate){ //var currentDateStr=expiryDate; var currentDate =

  • 0

I am comparing two dates in javascript

function checkCurrentDate(expiryDate){
//var currentDateStr=expiryDate;
var currentDate = new Date();
var month = currentDate.getMonth() + 1;
var day = currentDate.getDate();
var year = currentDate.getFullYear();
currentDate = month + "/" + day + "/" + year;
var dArr = currentDate.split("/");
currentDate = dArr[0]+ "/" +dArr[1]+ "/" +dArr[2].substring(2);  
var currentExpiryDateStr = expiryDate;

if(currentExpiryDateStr == currentDate){    

} 

if(currentExpiryDateStr < currentDate){

    alert("Expiry date is earlier than the current date.");
    return false;
}
}

currently the dates are in “currentExpiryDateStr ” is “11/10/12” and “currentDate” is “11/8/12” now in this condition “if(currentExpiryDateStr < currentDate)” is returning true and is entering in if condition but this condition should return false and should not enter in this if condition. It was working before but dont know why it is not working now.

  • 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-14T03:34:23+00:00Added an answer on June 14, 2026 at 3:34 am

    Just add this 2 lines before your if condition

    currentExpiryDateStr=Date.parse(currentExpiryDateStr);
    currentDate=Date.parse(currentDate);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm comparing two dates and my code goes like this. jQuery('.newAppointment a.ui-state-default').click(function() { var
I need to add custom validator for comparing two dates - start date and
Is there an easy way of comparing weeks in two dates like this... var
I am comparing two dates and trying to determine the max of the two
I need to compare two date in javascript. In my code I am calling
Possible Duplicates: Comparing dates How to compare two dates in Objective-C i want to
Thanks to all the other SO questions regarding javascript and comparing dates, I was
I want to override this method for comparing two objects. -(BOOL)isEqual:(id)object Calling function -(void)overridemethod(
Possible Duplicate: How can I calculate the difference between two dates? NSDate, comparing two
I want to compare two dates in PHP. One date is the date due,

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.