In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Xiaobian to share with you how JS to achieve the acquisition of time has been time and timestamp conversion, I believe most people do not know how to share this article for your reference, I hope you have a lot of harvest after reading this article, let us go to understand it together!
getCurrentMonthFirst=()=>{ var date=new Date(); date.setDate(1); return common.getdateNoTime(date);} getn days before getBeforeDate=()=>{ var n = n; var d = new Date(); var year = d.getFullYear(); var mon = d.getMonth() + 1; var day = d.getDate(); if (day 1) { mon = mon - 1; } else { year = year - 1; mon = 12; } } d.setDate(d.getDate() - n); year = d.getFullYear(); mon = d.getMonth() + 1; day = d.getDate(); const s = year + '-' + (mon
< 10 ? '0' + mon : mon) + '-' + (day < 10 ? '0' + day : day); return s;}根据两个日期,判断相差天数/** * @zhiparam sDate1 开始日期 如:2016-11-01 * @param sDate2 结束日期 如:2016-11-02 * @returns {nDays} 返回相差天数 */function daysBetween = (sDate1, sDate2) =>{ var time1 = Date.parse(new Date(sDate1)); var time2 = Date.parse(new Date(sDate2)); var nDays = Math.abs(parseInt((time2 - time1) / 1000 / 3600 / 24)); return nDays;} Determine the number of months difference between two dates according to bai/** * @zhiparam startDate Start Date e.g. 2016-11-01 * @param endStart End Date e.g. 2016-11-02 * @returns {intervalMonth} Returns the difference in months */function getIntervalMonth = (startDate, endStart) => { var startMonth = new Date(startDate).getMonth(); var endMonth = new Date(endStart).getMonth(); var intervalMonth = new Date(endStart).getFullYear() * 12 + endMonth - (new Date(startDate).getFullYear() * 12 + startMonth); return intervalMonth;} Gets the date entered several months ago/** *{param:DateTime} date Enter date (Y-MM-DD) *{param:number } monthNum Months */function getIntervalMonth =(startDate, endStart) => { var dateArr = date.split ('-'); var year = dateArr[0]; //Get the year of the current date var month = dateArr[1]; //Get the month of the current date var day = dateArr[2]; //Get the day of the current date var days = new Date (year, month, 0); days = days.getDate(); //Get the days of the month in the current date var year2 = year; var month3 = parseInt(month) - monthNum; if (month3 days2) { day2 = days2; } if (month3
< 10) { month3 = '0' + month3; } var t2 = year2 + '-' + month3 + '-' + day2; return t2;}时间戳转换时间function getdate= (date) =>{ var now = new Date(date), y = now.getFullYear(), m = now.getMonth() + 1, d = now.getDate(); return y + '-' + (m
< 10 ? '0' + m : m) + '-' + (d < 10 ? '0' + d : d) + ' ' + now.toTimeString().substr(0, 8);}时间戳转换时间 - 无时分秒function getdateNoTime= (date) =>{ var now = new Date(date), y = now.getFullYear(), m = now.getMonth() + 1, d = now.getDate(); return y + '-' + (m
< 10 ? '0' + m : m) + '-' + (d < 10 ? '0' + d : d);}时间戳转换时间-无日期function getdateTime= (date) =>{ var now = new Date(date), y = now.getFullYear(), m = now.getMonth() + 1, d = now.getDate(); return now.toTimeString().substr(0, 8);} Get current date function formatting= (time) => { let date = new Date(); if (time !== undefined) { date = new Date(time); } const seperator1 = '-'; const year = date.getFullYear(); let month = date.getMonth() + 1; let strDate = date.getDate(); if (month >= 1 && month = 0 && strDate
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.