通过在Javascript中传递月份和年份来获取开始日期和结束日期

时间:2015-09-28 04:54:39

标签: javascript date

我想知道如何通过将月份名称传递给以下函数来获取开始日期和结束日期:

var myMonth="September 2015"

我尝试了此链接Get first and last date,但输入与链接

中的输入不同

1 个答案:

答案 0 :(得分:0)

根据您的问题,我认为您希望获得特定月份的第一个日期和最后日期。 我可以建议如下:

第一次约会:

var myMonth="September 2015" 
myMonth = "1 "+myMonth;
var d = new Date(myMonth);
d.getDate(); // will give the start date of the month

最后日期:

var myMonth="September 2015" 
myMonth = "1 "+myMonth;
var checkDate = new Date(myMonth);
var d = new Date(checkDate.getFullYear(), checkDate.getMonth() + 1, 0);
d.getDate(); // this will return the last date of the month

这是小提琴:How to immediately replace the current toast with a second one without waiting for the current one to finish?

相关问题