How to deal with the compatibility of easyui date and time box in IE
This time I will bring you how to deal with the compatibility of the easyui date and time box in IE, how to deal with the compatibility of the easyui date and time box in IENotesWhat are they? Here are actual cases. Let’s take a look.
A few days ago, the project entered the final stage of preparation for launch. The test suddenly found that the time obtained using the datetimebox plug-in of easyui could not be obtained later than the current time in IE. At that time This is what it says:
$(selector).datetimebox( { formatter : function(date) { var y = date.getFullYear(); var m = date.getMonth() + 1; var d = date.getDate(); var h = date.getHours(); //获取当前小时数(0-23) var mi = date.getMinutes(); //获取当前分钟数(0-59) var s = date.getSeconds(); var result = y + '-' + (m < 10 ? '0' + m : m) + '-' + (d < 10 ? '0' + d : d) + " " + (h < 10 ? '0' + h : h) + ":" + (mi < 10 ? '0' + mi : mi); //console.log(result+"--第127行"); if(second==false){ } else { result += ":" + (s < 10 ? '0' + s : s); } return result; }, parser : function(s) { var t = Date.parse(s); if (!isNaN(t)) { return new Date(t); } else { return new Date(); } } });
There is no problem when testing mainstream browsers such as Google Chrome. The initial echoed time can be displayed and the time can be selected. However, when I use Internet Explorer, I find that I cannot select the time and the echoed date is wrong. is the current time. Debugging After a long time, I found out that ie browser does not support the parse() method of js. The parse() method parses the date and converts it into milliseconds of the date.
formatter is the format for formatting dates. The parser parses your formatted date
Because parse cannot be used in IE, it is impossible to parse and display the formatted date time in IE. The following is the code I modified myself:
$(selector).datetimebox( { formatter : function(date) { var y = date.getFullYear(); var m = date.getMonth()+1; var d = date.getDate(); var h = date.getHours(); var min = date.getMinutes(); return y+'-'+(m<10?('0'+m):m)+'-'+(d<10?('0'+d):d)+' '+(h<10?('0'+h):h)+':'+min; }, parser : function(s) { var ss = (s.split(" ")); var ymd = ss[0].split("-"); var hms = ss[1].split(":"); //console.log(ymd+" "+hms); var y = parseInt(ymd[0],10); var m = parseInt(ymd[1],10); var d = parseInt(ymd[2],10); var h = parseInt(hms[0],10); var min = parseInt(hms[1],10); if (!isNaN(y) && !isNaN(m) && !isNaN(d) && !isNaN(h) && !isNaN(min)){ return new Date(y,m-1,d,h,min); } else { return new Date(); } } });
The date formatted by formatter is xxxx-xx-xx xx:x. Therefore, when parsing below, the date and time are first separated by the space between them. ss[0]==xxxx-xx-xx, ss[1]==xx:xx. In this case, use - and: to divide them into numbers. In this case, write new directly. The correct date format can be returned in the parameters of Date()~~ Well, after testing, it is perfectly compatible with the cheating browser IE.
I suddenly discovered a bug in this method when using it today, that is, if there is no data in the datetime time frame at the beginning, a split error will be reported, so I modified it today and added an empty judgment:
if(s==""){ return new Date(); }else{ //alert(s); var ss = (s.split(" ")); var ymd = ss[0].split("-"); var hms = ss[1].split(":"); //console.log(ymd+" "+hms); var y = parseInt(ymd[0],10); var m = parseInt(ymd[1],10); var d = parseInt(ymd[2],10); var h = parseInt(hms[0],10); var min = parseInt(hms[1],10); if (!isNaN(y) && !isNaN(m) && !isNaN(d) && !isNaN(h) && !isNaN(min)){ return new Date(y,m-1,d,h,min); } else { return new Date(); } }
It should be noted here that s is a string type~so you cannot use s==null to make the judgment condition~
I believe you have mastered the method after reading the case in this article, more Please pay attention to other related articles on php Chinese website for wonderful content!
Recommended reading:
##vue determines whether the input content has spaces
The above is the detailed content of How to deal with the compatibility of easyui date and time box in IE. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Nowadays, many mobile phones claim to support Bluetooth 5.3 version, so what is the difference between Bluetooth 5.3 and 5.2? In fact, they are essentially subsequent updated versions of Bluetooth 5, and there is not much difference in most performance and functions. The difference between Bluetooth 5.3 and 5.2: 1. Data rate 1 and 5.3 can support higher data rates up to 2Mbps. 2. While 5.2 can only reach a maximum of 1Mbps, it means that 5.3 can transmit data faster and more stably. 2. Encryption control enhancement 2. Bluetooth 5.3 improves encryption key length control options, improves security, and can better connect to access control and other devices. 3. At the same time, because the administrator control is simpler, the connection can be more convenient and faster, which is not possible in 5.2.

The performance of i77700 is completely sufficient to run win11, but users find that their i77700 cannot be upgraded to win11. This is mainly due to restrictions imposed by Microsoft, so they can install it as long as they skip this restriction. i77700 cannot be upgraded to win11: 1. Because Microsoft limits the CPU version. 2. Only the eighth generation and above versions of Intel can directly upgrade to win11. 3. As the 7th generation, i77700 cannot meet the upgrade needs of win11. 4. However, i77700 is completely capable of using win11 smoothly in terms of performance. 5. So you can use the win11 direct installation system of this site. 6. After the download is complete, right-click the file and "load" it. 7. Double-click to run the "One-click

Methods for setting browser compatibility include selecting appropriate HTML and CSS standards, using CSS prefixes and resets, using browser compatibility prefix libraries, detecting browser features, using browser compatibility tools, and conducting cross-browser testing. Detailed introduction: 1. Choose appropriate HTML and CSS standards. When writing HTML and CSS codes, you should try to follow W3C standards. Different browsers will have different support for standards, but following standards can maximize compatibility. sex; 2. Use CSS prefixes, etc.

The Go language has very good compatibility on Linux systems. It can run seamlessly on various Linux distributions and supports processors of different architectures. This article will introduce the compatibility of Go language on Linux systems and demonstrate its powerful applicability through specific code examples. 1. Install the Go language environment. Installing the Go language environment on a Linux system is very simple. You only need to download the corresponding Go binary package and set the relevant environment variables. Following are the steps to install Go language on Ubuntu system:

With the continuous development of modern technology, wireless Bluetooth headsets have become an indispensable part of people's daily lives. The emergence of wireless headphones frees our hands, allowing us to enjoy music, calls and other entertainment activities more freely. However, when we fly, we are often asked to put our phones in airplane mode. So the question is, can I use Bluetooth headphones in airplane mode? In this article, we will explore this question. First, let’s understand what airplane mode does and means. Airplane mode is a special mode for mobile phones

The software in the win10 system has been perfectly optimized, but for the latest win11 users, everyone must be curious about whether this system can be supported, so the following is a detailed introduction to the win11 software that does not support win10. Come and find out together. Does win11 support win10 software: 1. Win10 system software and even Win7 system applications are well compatible. 2. According to feedback from experts who use the Win11 system, there are currently no application incompatibility issues. 3. So you can upgrade boldly with confidence, but ordinary users are advised to wait until the official version of Win11 is released before upgrading. 4. Win11 not only has good compatibility, but also has Windo

1. Right-click the program and find that the [Compatibility] tab is not found in the properties window that opens. 2. On the Win10 desktop, right-click the Start button in the lower left corner of the desktop and select the [Run] menu item in the pop-up menu. 3. The Win10 run window will open, enter gpedit.msc in the window, and then click the OK button. 4. The Local Group Policy Editor window will open. In the window, click the [Computer Configuration/Administrative Templates/Windows Components] menu item. 5. In the opened Windows component menu, find the [Application Compatibility] menu item, and then find the [Remove Program Compatibility Property Page] setting item in the right window. 6. Right-click the setting item, and in the pop-up menu

Best practices to solve PHP function compatibility issues: Use versioned function names (for example: array_map_recursive()) Leverage function aliases (for example: functionarray_map($callback,$array){...}) to check function availability (for example: if (function_exists('array_map_recursive')){...}) use namespace (for example: namespaceMyNamespace{...})
