Recently, the editor is working on a conference room reservation function. This function is like choosing a seat when buying a movie ticket. You can see which time period the conference room is free, what equipment is available, etc. Since I am making an APP, the APP must be compatible with both Android and IOS. I used Google Chrome for the initial development and debugging. I did not use other browsers for testing. Who knew that there would be a big problem left in the end? hidden dangers. Below is my interface.
Question 1:
This interface uses a lot of date type calculations. When we use JavaScript to instantiate a date object, we can use it like this :
var date =new Date();
The above code is to get the current date. This code can be run in Firefox, Chrome, and Safari browsers. But if I want to get the date based on a string, the problem comes. Look at the code below.
var date =new Date("2016-05-31 08:00");
This code is to get the date specified in the characters. It can be run in Firefox and Chrome, but when placed in Safari, an error will be reported. The error is NaN, which means Not a Number. Because of this error, Apple phones could not run the interface I developed normally. I was almost depressed at the time. I wrote 300 lines of js, almost all of which were related to time, either taking values or assigning values, or calculating. Now IOS not support. . . . . . .
I searched on the Internet and wrote the code like this:
var date =new Date("2016/05/31 08:00");
In this way, Android and IOS can share it. I wrote a function and replaced it!
function GetDateDiff(startDiffTime, endDiffTime) {
$("#timeDate').val("2016-05-30T08:30");
JavaScript's new date and other date functions encountered in Safari Pit
Related videos:JS built-in object-Date date object-JavaScript basic video Tutorial
The above is the detailed content of Compatibility issues encountered by Date objects in JavaScript between Safari and IOS. For more information, please follow other related articles on the PHP Chinese website!