Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何使用 Javascripts 获取上个月的开始日期和结束日期。
例如:
今天 - 2013 年 9 月 7 日
我需要得到输出
上个月开始日期:01/06/2013 上个月结束日期:30/06/2013
function f() { var date = new Date(); var firstDay = new Date(date.getFullYear(), date.getMonth()-1, 1); var lastDay = new Date(date.getFullYear(), date.getMonth(), 0); alert(firstDay+"==="+lastDay); }