Skip to content

Instantly share code, notes, and snippets.

@stwilz
Created January 22, 2019 23:48
Show Gist options
  • Save stwilz/29f226f2c5c7c61d2bca1c2b1d58645b to your computer and use it in GitHub Desktop.
Save stwilz/29f226f2c5c7c61d2bca1c2b1d58645b to your computer and use it in GitHub Desktop.
const dateStringtoObj = string => {
const [date, time, timezone] = string.split(/T|\+/g);
const [hours, minutes, seconds] = time.split(/:/g);
return {
date,
time,
timezone,
hours: parseInt(hours, 10),
minutes: parseInt(minutes, 10),
seconds: parseInt(seconds, 10),
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment