所以我唯一的價值就是這個月。例如,今年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