//日历打印 function getWeek(date) { //获取星期 return new Array("日", "一", "二", "三", "四", "五", "六")[new Date(date).getDay()]; } function addDays(date,count) { //添加日期 var dd = new Date(date); dd.setDate(dd.getDate() + count); var y = dd.getFullYear(), m = dd.getMonth() + 1, d = dd.getDate(); return y + "-" + (m < 10 ? "0" + m : m) + "-" + (d < 10 ? "0" + d : d); } function disDays(date1, date2){ //根据两个容器日期的值相减的得到天数 date1 = date1.split("-"); date2 = date2.split("-"); var start = new Date(date1[0], date1[1] - 1, date1[2]); var end = new Date(date2[0], date2[1] - 1, date2[2]); return parseInt((end - start) / 1000 / 60 / 60 / 24); } function printDate(){ //创建Html片段 var startDate = $("#txt_create_start_date").val(); var endDate = $("#txt_create_end_date").val(); var disCount = disDays(startDate,endDate); var html = "<table><thead>"; html += "<th width='68'>正常<br/>工时累计</th>"; html += "<th width='69'>加班<br/>工时累计</th>"; for (var i=0,len=disCount; i<len+1; i++){ var curr = addDays(startDate,i); var short = curr.substr(5,curr.length).replace("-","."); html += "<th width='70' class='hasLine'>"; html += "<span class='t-line'>"+short+" 周"+getWeek(curr)+"</span>"; html += " <span> 正常   加班</span>"; html += "</th>"; } html += "</thead></table>"; $("#table-right-head").html(html); }
根据开始和结束日期打印HTML日历片段
最新推荐文章于 2021-06-05 02:20:41 发布