 <p>it's working properly here. Make sure you're using returns inside a function.</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>function test(a, b){ var dateFrom = Date.parse(a); var dateTo = Date.parse(b); if ( dateFrom &gt; dateTo ) { console.log( a, ' &gt; ',b ); return false; } console.log( a, ' &lt;= ', b ); return true; } var result = test('06-05-2016 13:05', '13-05-2016 13:05'); document.getElementById('test').innerHTML = result; console.log( result )</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="test"&gt; &lt;/div&gt;</code></pre> </div> </div> </p>