所以我唯一的价值就是这个月。例如,今年2月,我如何知道第一周的日子是1,第二周是2 - 8,依此类推。有没有办法获得本月的一周的日期?
我正在使用它来生成报告,并且还应该有一个每周报告。也许你可以给我另一种拉本报告的方式。
我为这个系统使用了经典的asp和javascript。
所以我唯一的价值就是这个月。例如,今年2月,我如何知道第一周的日子是1,第二周是2 - 8,依此类推。有没有办法获得本月的一周的日期?
我正在使用它来生成报告,并且还应该有一个每周报告。也许你可以给我另一种拉本报告的方式。
我为这个系统使用了经典的asp和javascript。
库Moment.js会帮助你。
获取当月的天数。
moment("2012-02", "YYYY-MM").daysInMonth() // 29
moment("2012-01", "YYYY-MM").daysInMonth() // 31
(http://momentjs.com/docs/#/displaying/days-in-month)
此方法可用于设置一周的某一天,其中星期日为0和周六6:
moment().day(Number|String);
moment().day(); // Number
moment().days(Number|String);
moment().days(); // Number
这是一个很好用的asp-classic解决方案已经有一段时间了。
<%
' Copyright (c) 2008, reusablecode.blogspot.com; some rights reserved.
'
' This work is licensed under the Creative Commons Attribution License. To view
' a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or
' send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California
' 94305, USA.
' Check if a year is a leap year.
function isLeapYear(someYear)
if someYear Mod 4 = 0 and (someYear Mod 100 <> 0 or (someYear Mod 100 = 0 and someYear Mod 400 = 0)) then
isLeapYear = True
else
isLeapYear = False
end if
end function
' Returns the number of days in a given month (and in the case of February, for the given year).
' REQUIRES: isLeapYear()
function MonthDays(someMonth, someYear)
select case someMonth
case 1, 3, 5, 7, 8, 10, 12
MonthDays = 31
case 4, 6, 9, 11
MonthDays = 30
case 2
if isLeapYear(someYear) then
MonthDays = 29
else
MonthDays = 28
end if
end select
end function
%>
要使用它
<%
Dim daysinmonth
'Number if days in January 2014
daysinmonth = MonthDays(1, 2014)
%>
你想要一个[标签:Java脚本]或[标签:ASP-经典]解决方案? – Lankymart