I am trying to identify whether given date-time is future date and time or not. For e.g. My current date time is '25-04-2010 08:26 PM' and if I pass '25-04-2010 09:00 PM' to a JavaScript function, then it should return me '1' if that date-time is future date & time otherwise it should return me '0'.
I decided to do this using timestamp. So I just wrote below code.
var myDate = new Date("April 25, 2011 21:16:00"); // Your timezone!
var myEpoch = myDate.getTime()/1000.0;
document.write(myEpoch);
var cur_date = new Date(); // Current date
var myEpoch1 = cur_date.getTime()/1000.0;
document.write("---"+myEpoch1);
var diff=myEpoch-myEpoch1; // If diff comes minus value, then it is past date-time, otherwise it is future data-time
alert(diff);
thanks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With