The General direct new Date () is not a compatibility issue, and the new date (datetimeformatstring) often has browser compatibility issues, why some format browsers in datetimeformatstring are incompatible.
1. No reference
| 12 |
//无参 所有浏览器都兼容vardateTime = newDate(); |
2. Date parameters
| 12 |
//日期参数 格式1vardateTime = newDate("2017-09-12"); |
A. IE
> ie9-(Incompatible)
> ie9+ (compatible, including IE9)
B. Firefox (compatible)
C. Google (compatible)
| 12 |
//日期参数 格式2 所有浏览器都兼容vardateTime = newDate("2017/09/12"); |
3. Date and Time parameters
| 12 |
//日期时间参数 格式1vardateTime = newDate("2017-09-12 13:41:00"); |
A. IE (incompatible, no matter which version)
B. Firefox (not compatible)
C. Google (compatible)
| 12 |
//日期时间参数 格式2 所有浏览器都兼容vardateTime = newDate("2017/09/12 13:42:00"); |
| 12 |
//日期时间参数 格式3vardateTime = newDate("2017-09-12T13:42:00"); |
A. IE
> ie9-(Incompatible)
> ie9+ (Compatible)
> IE9 (Semi-compatible 8-hour time difference)
B. Firefox (compatible)
C. Google (half-compatible 8-hour time difference)
| 12 |
//日期时间参数 格式4vardateTime = newDate("2017/09/12T13:42:00"); |
A. IE (half-compatible 1-hour time difference)
B. Firefox (not compatible)
C. Google (not compatible)
In all, the formats supported by all major browsers are: var dateTime = new Date ("2017/09/12 13:42:00");
So the solution is to convert datetimeformatstring to YYYY/MM/DD HH:MM:SS formatted string
JS date () Day function Browser compatibility problem solving method