Why converting new.Date() .toISOString() changes the time? : <p>I'm inserting a date in a database in two different format. </p>

<p><strong>this is inserting as Datetime</strong></p>

<pre><code>    var mydate;
    mydate = new Date();
    document.getElementById('clockinhour').value = mydate.toISOString().slice(0, 19).replace('T', ' ');
</code></pre>

<p><strong>Output A</strong></p>

<pre><code>2017-06-21 20:14:31 
</code></pre>

<p><strong>this is inserting as varchar :</strong></p>

<pre><code>document.getElementById('clocked_in_time').value = Date();
</code></pre>

<p><strong>Output B</strong></p>

<pre><code>Wed Jun 21 2017 16:14:31 GMT-0400 (Eastern Standard Time)
</code></pre>

<p>Output B is the correct time but I need to display output A. What causes the time to change when converted toISOString? How can I fix this?</p>
