Let’s talk about this application scenario first:
Read data from an XML file, and then return the data inside to the page for drawing using a third-party plug-in.
Of course the data read in XML is of string type, and if you want to use the time mode of the X-axis of the drawing plug-in (this can more reasonably customize the x-axis range, x-axis data format, etc.). The data must be converted into a standard time object. At this time, the built-in Date type in js comes in handy:
var date = new Date();
//The input field with id time contains the time information extracted from xml
date.setHours($("#time" ).val().substring( 0, 2) 8);
date.setMinutes($("#time" ).val().substring(2, 4));
date.setSeconds($("#time" ).val ().substring(4, 6));
The time type in XML is in the format of hours, minutes and seconds (such as 083100). After taking out the data, you can use setHours, setMinutes , setSeconds and other time-setting functions to instantiate the Date object.
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn