国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

JavaScript獲取某年某月的最后一天附截圖

2019-11-20 14:25:46
字體:
來源:轉載
供稿:網友

1、實現源碼

<!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html> <head> <title>JavaScript獲取某年某月的最后一天</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width"> <script type="text/javascript"> /** * 獲取某年某月的最后一天 */ function getLastDayOfMonth(year,month) { //獲取本年本月的第一天日期 var date = new Date(year,month-1,'01'); //設置日期 date.setDate(1); //設置月份 date.setMonth(date.getMonth() + 1); //獲取本月的最后一天 cdate = new Date(date.getTime() - 1000*60*60*24); //打印某年某月的最后一天 alert(cdate.getFullYear()+"年"+(Number(cdate.getMonth())+1)+"月最后一天的日期:"+cdate.getDate()+"日"); //返回結果 return cdate.getDate(); } </script> </head> <body> <input type="button" value="獲取某年某月的最后一天" onclick="getLastDayOfMonth(2014,6)"/> </body> </html>

2、實現結果

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 丹棱县| 昆山市| 邹平县| 温宿县| 四子王旗| 曲麻莱县| 长宁县| 洛南县| 肇源县| 碌曲县| 宜黄县| 容城县| 出国| 明星| 灌南县| 晋江市| 岳池县| 南雄市| 屯昌县| 遂溪县| 祁连县| 白水县| 丹棱县| 肥城市| 阜南县| 临夏市| 青浦区| 嘉义县| 上高县| 西城区| 清远市| 黑龙江省| 周宁县| 潼南县| 龙口市| 巨野县| 永济市| 清水河县| 阿巴嘎旗| 瓮安县| 丽水市|