问题
When I try to convert a string value to a Date I get the error message "Invalid date"
timestamp : string = "2017:03:22 08:45:22";
.
.
let time = new Date(timestamp);
console.log("Time: ",time); //here I get   Time: Invalid date
    回答1:
Since your string must be in ISO date format you can change it like in the code below:
let timestamp : string = "2017:03:22 08:45:22";
let timestampISO : string = timestamp.replace(':','-').replace(':','-').replace(' ','T');
let time = new Date(timestampISO);
console.log("Time: ",time);
回答2:
Your date must be a version of an ISO format.
To be more specific, it must be a version of ISO8601. See more here.
Example:
let time = new Date("2017/03/22 08:45:22");
    来源:https://stackoverflow.com/questions/42947680/cant-fromat-string-to-date