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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:20:47+00:00 2026-05-25T12:20:47+00:00

I am having to try to determine whether a date from a hidden field,

  • 0

I am having to try to determine whether a date from a hidden field, formatted mm/dd/yyyy, is less than today. if it is, I want to let the person know that a subscription has expired. I have had this working on some occasions but it is not reliably doing it??

//this is the expiration date that is in a hidden field
var expireDate = $("#expire").val();

//here I am trying to setup a new date for today and change the output to match the date
//format for the hidden field, i.e. mm/dd/yyyy
var a = new Date();
var b = a.toISOString().split("T")[0].split("-");
var ca = b[1] + "/" + b[2] + "/" + b[0];


//now I want to compare the 2 and if the expiration date is less than today, display a warning message                      
if (expireDate < ca) {
   $("<div class=\"message-warning\">This subscription is expired</div>")
    .insertAfter("#enddate");
};
  • 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-25T12:20:48+00:00Added an answer on May 25, 2026 at 12:20 pm

    You’re comparing the numerical value of strings, which happen to be the string representation of dates in mm/dd/yyyy format. I’m guessing that your “inconsistent” results are that it works if the old date is an earlier month than today.

    Instead of converting a to a string, convert expireDate to a Date object. Then compare.

    var expireDateStr = $("#expire").val();
    var expireDateArr = expireDateStr.split("/");
    var expireDate = new Date(expireDateArr[2], expireDateArr[0], expireDateArr[1]);
    var todayDate = new Date();
    
    if (todayDate > expireDate) {
       $("<div class=\"message-warning\">This subscription is expired</div>")
        .insertAfter("#enddate");
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just created an iPhone app and am having friends try it out, but
I'm having a problem with TRY...CATCH blocks. Can someone explain why the following code
I'm often having code written as follows try: self.title = item.title().content.string except AttributeError, e:
I am having an issue where I try to access the Lists.asmx web service
I am having a really bad issue where no matter what I try, the
I am having this most annoying issue when I try to rebuild my solution
I am having problems using django-tagging . I try to follow the documentation but
Am having a batch file used to update certain files. However when i try
Im having some trouble with an oracle database. Every time i try to connect,
I'm having trouble getting command line arguments passed to Python programs if I try

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.