獲取當前系統日期和時間,ASP輸出可以這樣寫:<%=now()%>
Year(now()) 獲取年份, ASP輸出:<%=Year(now())%>
Month(now()) 獲取當前月份,ASP輸出:<%=Month(now())%>
day(now()) 獲取當天數,ASP輸出:<%=day(now())%>
Minute(now()) 獲取分鐘數,ASP輸出:<%=Minute(now())%>
Second(now()) 獲取秒鐘數,ASP輸出:<%=Second(now())%>
date() 獲取當前系統日期,格式為:2004-2-28
time() 獲取當前系統時間,格式為:22:24:59
函數調用格式:FormatDateTime(Date[, NamedFormat])
FormatDateTime函數的語法有以下參數:
參數 描述
Date 必選,要被格式化的日期表達式。
NamedFormat 可選,指示所使用的日期/時間格式的數值,如果省略,則使用vbGeneralDate。
設置
NamedFormat參數可以有以下值:
vbGeneralDate 0 顯示日期和/或時間;如果有日期部分,則將該部分顯示為短日期格式;如果有時間部
分,則將該部分顯示為長時間格式;如果都存在,則顯示所有部分。
vbLongDate 1 使用計算機區域設置中指定的長日期格式顯示日期。
vbShortDate 2 使用計算機區域設置中指定的短日期格式顯示日期。
vbLongTime 3 使用計算機區域設置中指定的時間格式顯示時間。
vbShortTime 4 使用24小時格式(hh:mm)顯示時間。
示例:
<%
response.write formatdatetime(now,0)&"<br>"
response.write formatdatetime(now,1)&"<br>"
response.write formatdatetime(now,2)&"<br>"
response.write formatdatetime(now,3)&"<br>"
response.write formatdatetime(now,4)&"<br>"
%>
顯示如下:
2007-9-5 1:52:27
2007年9月5日
2007-9-5
1:52:27
01:52
|