Aug 1, 2016
0
Level 8
JavaScript Issue with New Date
Hello,
I have very strange issue. Js returning me correctly now date but, when i giving him other date it's adding +1 hour. problem is in line var end = new Date(Date.parse(thisDateT)); Date.parse(thisDateT) - still have correct date but after using new Date everything changing. It adding +1 hour. Can't understand how to solve it. Please see my code below.
//Time now is Mon Aug 01 2016 14:31:46 GMT+0100 (BST)
var now = new Date();
var dt = $('#finish_at'+(i)).val(); //giving date 2016-08-01 14:40
var thisDateT = dt.substr(0, 10) + "T" + dt.substr(11, 8);
var end = new Date(Date.parse(thisDateT));
var distance = end - now;
console.log('End:',end); //returning me End: Mon Aug 01 2016 15:40:00 GMT+0100 (BST)
//as you see 1 hour difrience :(
console.log('Now:',now); //returning me Now: Mon Aug 01 2016 14:31:46 GMT+0100 (BST)
Please or to participate in this conversation.