 <p>When using == or != or > or &lt; if the types of the two expressions are different it will attempt to convert them to string, number, or Boolean etc<br/> use below code to compare </p> <pre><code>if ( Date.parse ( currentdate) &gt; Date.parse ( enddate) ) { // your code } </code></pre>