This article explains how to compare 2 Date Objects in Javascript
Tech-Today

This article explains how to compare 2 Date Objects in Javascript


The best way to compare 2 Date objects using javascript is to get its long equivalent.

For example we have a date in this format: mm-dd-yyyy and we want to compare them. We will declare the javascript function this way:

function compareDate(a, b) {
var temp, from, to;

from = new Date();
temp = a.split("-");
from.setFullYear(temp[2], temp[0] - 1, temp[1]);

to = new Date();
temp = b.split("-");
to.setFullYear(temp[2], temp[0] - 1, temp[1]);

if(from.getTime() > to.getTime()) {
return false;
}
return true;
}

For setFullYear's definition:
http://www.w3schools.com/jsref/jsref_setfullyear.asp




- How To Output Mysql Query Result Into A File
See sql script below: SELECT code, name, continent, region FROM country INTO OUTFILE 'c:/temp/countries.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n'; ...

- Create A Custom Json String Deserializer In Java
On normal cases we really have a lot of ways in doing so, we can use jaxb, jackson and more. But in some cases we really need to improvised, for example in the project I'm working right now I have a date string from a .net application in this format:...

- How To Create An Xsd And Xml Data From Model Entity In Java
The following code will show how to generate a xsd base on a given model and a sample xml with data. Let's assume you have a CustomerList model, which is an array of Customer. JAXBContext context; try { context = JAXBContext.newInstance(CustomerList.class);...

- Add A Jquery Datepicker On Jquery Dialog Box Via Load Method
Recently I've worked on a form that requires a jquery datepicker to be rendered inside jquery's dialog element. Where I encountered several problems like: 1.) datepicker() should be invoke inside dialog 2.) the dialog created (div) should be remove...

- Allowing Url Query String In Codeigniter
As we all know codeigniter uses segment-based as url, example: Just like these: classname/methodname/parameter1/paramenter2, index.php/index/login/user/password Unfortunately, I was developing a web application that would accept payments via paypal. And...



Tech-Today








.