Skip to content
This repository has been archived by the owner on Jul 31, 2020. It is now read-only.

Date.parse two different times returning same time... #116

Open
timgudex opened this issue Oct 16, 2017 · 0 comments
Open

Date.parse two different times returning same time... #116

timgudex opened this issue Oct 16, 2017 · 0 comments

Comments

@timgudex
Copy link

Date.parse("2017-12-16 T01:00:00 UTC");
returns Saturday, December 16, 2017 12:00:00 PM

Date.parse("2017-12-16 T02:00:00 UTC");
returns Saturday, December 16, 2017 12:00:00 PM
should return Saturday, December 16, 2017 1:00:00 PM

I fixed manually by creating new Date

function createDate(dateString){

var dateSplit;
var dateObj;
var timeObj;

dateSplit = dateString.split("T");

dateObj = dateSplit[0].split("-");
timeObj = dateSplit[1].replace("Z", "").split(":");

return new Date(Date.UTC(dateObj[0],dateObj[1],dateObj[2],timeObj[0],timeObj[1],timeObj[2]));

}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant