JS with Date object processing time to implement ideas and code _ basic knowledge

Source: Internet
Author: User
first of all, let's talk about the application scenario :
Read the data from the XML file, and then return the data inside to the page and draw with a third party plug-in.

The data that is read in XML is, of course, a string type, and if you want to use the drawing plug-in X-axis time mode (which makes it more reasonable to customize such as the x-axis range, the x-axis data format, and so on). You must convert the data to a standard time object. The date type built into JS this time comes in handy:
Copy Code code as follows:

var date = new Date ();
The input field with ID time contains the information extracted in 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 the format of hours in minutes (for example, 083100), which can be used to instantiate the date object using functions such as sethours, Setminutes, setseconds, and so on.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.