Examples of tool functions of web development compared with the time, web instances

Source: Internet
Author: User

Examples of tool functions of web development compared with the time, web instances

Examples of tool functions of web development compared with time

Js time size comparison, in the format of yyyy-MM-dd hh: mm: ss

Encapsulate the time comparison into a tool function:

/*** Compare the two time formats *: yyyy-MM-dd hh: mm: ss * @ param {Object} inintime start time * @ param {Object} endTime end time */var getDataLarge = function (beginTimeString, endTimeString) {var B = beginTimeString. replace (/-/g, '/'); var e = endTimeString. replace (/-/g, '/'); var bs = Date. parse (B); var es = Date. parse (e); // console. log (bs); // console. log (es); var disparityTime = (es-bs)/3600/1000; return disparityTime ;}

Usage:

Prepare data first: one start time and one end time

Time Format: yyyy-MM-dd hh: mm: ss

Var beginTime1 = "2011-01-01"; var endTime1 = "2011-02-01"; // start time and date joining var start_date_time = beginTime1 + "" + "00" + ": "+" 01 "+": 00 "; // end time and date concatenation var end_date_time = endTime1 +" "+" 00 "+": "+" 01 "+ ": 00 "; // disparityTime> 0 End Time is large, disparityTime <0 End Time is small, disparityTime = 0 date is equal var disparityTime = getDataLarge (start_date_time, end_date_time); if (disparityTime <0) {alert ("high start time");} else if (disparityTime> 0) {alert ("high end time");} else if (disparityTime = 0) {alert ("Equal ");}

The above is an example of a tool function that compares the time and size of web development. If you have any questions, please leave a message or go to the community on this site for discussion. Thank you for reading this article and hope to help you, thank you for your support!

Related Article

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.