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!