aspdotnet-suresh offers articles and tutorials,csharp dot net, articles and tutorials,VB.NET Articles,Gridview articles,code examples of 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

JQuery Check Given Date Greater than Current Date or Today Date JavaScript

Aug 27, 2013

Here I will explain how to use jQuery to check given date greater than current date or today date in JavaScript or check date greater than current date using JavaScript / jQuery.

To implement this we need to write the code like as shown below

<html xmlns="">
<title>jQuery Check Given Date Time Greater than Current Date time in JavaScript</title>
<script type="text/javascript" src=""></script>
<script type="text/javascript">
$(function() {
$('#btnConvert').click(function() {
var param1 = new Date();
var ddate = $('#txtdate').val();
var time = $('#txttime').val();
var hours = Number(time.match(/^(\d+)/)[1]);
var minutes = Number(time.match(/:(\d+)/)[1]);
var format = time.match(/\s(.*)$/)[1];
if (format == "PM" && hours < 12) hours = hours + 12;
if (format == "AM" && hours == 12) hours = hours - 12;
var sHours = hours.toString();
var sMinutes = minutes.toString();
if (hours < 10) sHours = "0" + sHours;
if (minutes < 10) sMinutes = "0" + sMinutes;
ddate = ddate + " " + sHours + ":" + sMinutes + ":00";
var date1 = new Date(ddate);
var date2 = new Date();
if (date1 < date2) {
alert('Please Enter Date time Greater than Current Date time');
return false;
<td><b>Enter Date:</b></td>
<td><input type="text" id="txtdate" value="08/27/2013" /></td>
<td><b>Enter Time:</b></td>
<td><input type="text" id="txttime" value="10:00 PM" /></td>
<td><input type="button" id="btnConvert" value="Check Date" /></td>
For live demo click on below button to check whether given date time greater than current date time or not

Live Demo

Enter Date:
Enter Time:

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest,, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email


karthik said...

Hi suresh, your doing great job. thanks many times your site helping me to complete my tasks. now i want to know can we able to send sms from web page using my gsm modem. please help me and give me a solution. thank you once again

chaitu said...

not able check the sample

Unknown said...

There is bug in your live demo please check user can enter any date means ex. month as 22

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.