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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:33:28+00:00 2026-06-18T03:33:28+00:00

I am looking for some help, trying to compare 2 dates in JavaScript, but

  • 0

I am looking for some help, trying to compare 2 dates in JavaScript, but haven’t managed to find the exact answer on this site yet.

I am only just starting out with JavaScript and I get the impression that getting the current date\time is not a simple 1 line of code which I thought it would be. I thought I could use a ternary operator but maybe not. I hope I’m wrong but here is my dilemma.

I want to compare 2 dates. If date1 is before date2 then do something. If not then do something else.

  • date1: is the current date time. i.e. my system clock
  • date2: is a predefined value. I already have this value in the web page: ${expiredDateTime.format(“ddMyyyyhm”) I believe date 2 is a string but I’m no expert on jquery.

Any help with this would be great.

  • 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-18T03:33:29+00:00Added an answer on June 18, 2026 at 3:33 am

    Please try the below code:

    var user="12/11/2012/5/30";
    var arrdt= user.split("/");
    var userdt = new Date(arrdt[2], arrdt[1] - 1, arrdt[0],arrdt[3],arrdt[4]);
    var currdt = new Date();
    if (userdt < currdt) {
    alert("userdate is before current date");
    }else{
    alert("userdate is after current date");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Looking for some help with my SQL query. I am trying to find a
Sorry if this sounds simple, but I'm looking for some help to improve my
Looking for some help with my bash script. I am trying to write this
just looking for some help on this. I've tried a few different things and
I am having trouble making this work and am looking for some help. Currently
I'm looking for some help because I don't quite think I understand the Javascript
I have posted this a few times looking for some help, I cant seem
I'm looking for some help with an accessible toggle navigation I'm trying to create.
I'm looking at the weirdest thing and needs some help trying to identify what's
Looking for some help on my AJAX/jQuery implementation. I am trying to load some

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.