日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

计算本年 本月 本周的起始日期

發(fā)布時間:2023/12/18 编程问答 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 计算本年 本月 本周的起始日期 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

html:

<table><tr><td align="right" width="120px"> 銷售時間區(qū)間:</td><td><select id="ddlChoiceDate" name="ddlChoiceDate" runat="server" onchange="SelectChange(this.value);"><option value="選擇時間" selected>選擇時間</option><option value="今天">今天</option><option value="本周">本周</option><option value="本月">本月</option><option value="今年">今年</option></select></td><td align="left"><input type="text" id="txtOrd_CreateTimeStart" runat="server" width="85px" onfocus="DateTimeStart(this,'txtOrd_CreateTimeEnd');"disabled="" /><input type="text" id="txtOrd_CreateTimeEnd" runat="server" width="85px" onfocus="DateTimeEnd(this,'txtOrd_CreateTimeStart');"disabled="" /></td></tr></table> View Code

?js:

js: <script>//根據(jù)銷售時間區(qū)間下拉列表框的選擇判斷時間截止文本框是否可用 function TxtDisabled() {if ($("#ddlChoiceDate").val() == "選擇時間") {$("#txtOrd_CreateTimeStart").removeAttr("disabled"); //可用 $("#txtOrd_CreateTimeEnd").removeAttr("disabled"); //可用 } else {$("#txtOrd_CreateTimeStart").attr("disabled", "disabled"); //禁用 $("#txtOrd_CreateTimeEnd").attr("disabled", "disabled"); //禁用 }}$(document).ready(function () {TxtDisabled();});function SelectChange(selVal) {TxtDisabled();switch (selVal) {case "選擇時間":$("#txtOrd_CreateTimeStart").val(""); //txtOrd_CreateTimeStart $("#txtOrd_CreateTimeEnd").val(""); //txtOrd_CreateTimeEndbreak;case "今天":$("#txtOrd_CreateTimeStart").val(getThisDayTime("txtOrd_CreateTimeStart")); //txtOrd_CreateTimeStart $("#txtOrd_CreateTimeEnd").val(getThisDayTime("txtOrd_CreateTimeEnd")); //txtOrd_CreateTimeEndbreak;case "本周":$("#txtOrd_CreateTimeStart").val(getWeekTime("txtOrd_CreateTimeStart")); //txtOrd_CreateTimeStart $("#txtOrd_CreateTimeEnd").val(getWeekTime("txtOrd_CreateTimeEnd")); //txtOrd_CreateTimeEndbreak;case "本月":$("#txtOrd_CreateTimeStart").val(getMonthTime("txtOrd_CreateTimeStart")); //txtOrd_CreateTimeStart $("#txtOrd_CreateTimeEnd").val(getMonthTime("txtOrd_CreateTimeEnd")); //txtOrd_CreateTimeEndbreak;case "今年":$("#txtOrd_CreateTimeStart").val(getYearTime("txtOrd_CreateTimeStart")); //txtOrd_CreateTimeStart $("#txtOrd_CreateTimeEnd").val(getYearTime("txtOrd_CreateTimeEnd")); //txtOrd_CreateTimeEndbreak;default:break;}}var now = new Date();//獲取當前時間 var Year = now.getFullYear();//得到年 var Month = now.getMonth() + 1; //得到月 //getMonth()是以0開始的月份 //當前月值(1月=0,12月=11) var Day = now.getDate(); //得到日 var GDay = now.getDay();//得到星期幾 0:星期日 1:星期一 2:星期二 3:星期三 4:星期四 5:星期五 6:星期六 function getThisDayTime(id) {var beginTime = "";if (Day < 10) {beginTime = Year + "-" + Month + "-0" + Day; //格式 Y-m-d } else {beginTime = Year + "-" + Month + "-" + Day; //格式 Y-m-d }return beginTime;}//計算本周起始日期,并以 Y-m-d 形式返回。 function getWeekTime(id) {var Dy = Day - GDay;if (GDay == 0) {Dy -= 7;}if (id == "txtOrd_CreateTimeEnd") {Dy += 7;}var beginTime = "";if (Dy < 10) {beginTime = Year + "-" + Month + "-0" + Dy; //格式 Y-m-d } else {beginTime = Year + "-" + Month + "-" + Dy; //格式 Y-m-d }return beginTime;}//計算本月開始時間,并以Y-m-d 形式返回 function getMonthTime(id) { var Dy = 1;if (id == "txtOrd_CreateTimeEnd") {Dy = solarDays(Year, Month);}var beginTime = "";if (Dy < 10) {beginTime = Year + "-" + Month + "-0" + Dy; //格式 Y-m-d } else {beginTime = Year + "-" + Month + "-" + Dy; //格式 Y-m-d }return beginTime;}//計算今年開始時間,并以Y-m-d 形式返回 function getYearTime(id) {var beginTimes = "";if (id == "txtOrd_CreateTimeStart") {beginTimes = Year + "-01-01"; //格式 Y-m-d } else if (id == "txtOrd_CreateTimeEnd") {beginTimes = Year + "-12-31"; //格式 Y-m-d }return beginTimes;}//當月的天數(shù) function solarDays(y, m) {var solarMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);if (m == 2)return (((y % 4 == 0) && (y % 100 != 0) || (y % 400 == 0)) ? 29 : 28);elsereturn (solarMonth[m - 1]);}</script> View Code

?

轉(zhuǎn)載于:https://www.cnblogs.com/lk516924/p/4018529.html

創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎

總結(jié)

以上是生活随笔為你收集整理的计算本年 本月 本周的起始日期的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。