發現網上用js獲取某月最后一個的方式大多比較復雜,上個簡單的:
new Date(2013,4).toJSON().substring(0,10)
new Date(2013,4,0).toLocaleFormat('%Y-%m-%d')
顯示"2013-04-30"。
year+'-'+month+'-'+new Date(year,month,0).getDate();//獲取當月最后一天日期
OK。
另外,前兩種方法貌似IE上兼容性有問題,自己看着用吧
發現網上用js獲取某月最后一個的方式大多比較復雜,上個簡單的:
new Date(2013,4).toJSON().substring(0,10)
new Date(2013,4,0).toLocaleFormat('%Y-%m-%d')
顯示"2013-04-30"。
year+'-'+month+'-'+new Date(year,month,0).getDate();//獲取當月最后一天日期
OK。
另外,前兩種方法貌似IE上兼容性有問題,自己看着用吧
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。