Comparing two dates using if statement not working - javascript + nodejs : <p>Here my below code:</p>

<pre><code>var date = new Date().toLocaleString();
console.log(date); // output: 2018-01-15 16:39:00

var schedule = 2018-01-15 16:39:00 (which is coming from my html form, i putting this date in one input box and getting into variable called schedule).
console.log(schedule); // output: 2018-01-15 16:39:00


if(date === schedule) {
console.log('date is matched');
} else {
 console.log('error');
}
</code></pre>

<p>This will show correctly as output: // 'date is matched' 
(I am typing this date in input box without any date picker).</p>

<p>My problem is if i do this same code using date picker instead of writing date in input box.</p>

<p>My code:</p>

<pre><code>var date = new Date().toLocaleString();
console.log(date); // output: 2018-01-15 16:39:00

    var schedule = 2018-01-15 16:39:00 (which is coming from my html form,using date picker).
    console.log(schedule); // output: 2018-01-15 16:39:00


    if(date === schedule) {
    console.log('date is matched');
    } else {
     console.log('error');
    }
</code></pre>

<p>Now i am getting error in console.
Date picker which i am using <a href="https://www.npmjs.com/package/angularjs-datetime-picker" rel="nofollow noreferrer">https://www.npmjs.com/package/angularjs-datetime-picker</a></p>
