Skip to content

Instantly share code, notes, and snippets.

@cyper85
Created January 20, 2016 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cyper85/4c7e40e1e3ac2336e6d0 to your computer and use it in GitHub Desktop.
Save cyper85/4c7e40e1e3ac2336e6d0 to your computer and use it in GitHub Desktop.
var datum = new Date("2014-07-11T12:00Z");
console.log(datum.toGMTString());
// Ausgabe: Invalid Date
var datumString = "2014-07-11T12:00Z";
var datum = new Date(datumString);
if(datum.toGMTString() == "Invalid Date") {
// Ich arbeite wie gesagt nur mit GMT, daher ist das entfernen der Zeitzone einfach:
var zwischenDatum = new Date(datumString.replace(/[T]/g," ").replace(/[Z]/g,""));
datum.setTime(Date.parse(datumString.replace(/[T]/g," ").replace(/[Z]/g,""))-(zwischenDatum.getTimezoneOffset()*60*1000));
}
@cyper85
Copy link
Author

cyper85 commented Jan 20, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment