它是一個幫助開發人員格式化並返回有效日期和時間表達式的函數。
用法
FormatDateTime(date,format)
參數說明
date, 必需參數。
format,一個可選參數。指定要使用的日期或時間格式的值。它可以采用以下值 âˆ'
0 = vbGeneralDate - 默認值。
1 = vbLongDate - 返回日期。
2 = vbShortDate - 返回日期。
3 = vbLongTime - 返回時間。
4 = vbShortTime - 返回時間。
示例
<!DOCTYPE html>
<html>
<body>
<script language = "vbscript" type = "text/vbscript">
d = ("2013-08-15 20:25")
document.write("Line 1:" & FormatDateTime(d) & " <br />")
document.write("Line 2:" & FormatDateTime(d,1) & "<br />")
document.write("Line 3:" & FormatDateTime(d,2) & "<br />")
document.write("Line 4:" & FormatDateTime(d,3) & "<br />")
document.write("Line 5:" & FormatDateTime(d,4) & "<br />")
</script>
</body>
</html>
當你將它保存為 .html 並在 Internet Explorer 中執行它時,那麽上麵的腳本將產生以下結果——
Line 1:15/08/2013 8:25:00 PM Line 2:Thursday, 15 August 2013 Line 3:15/08/2013 Line 4:8:25:00 PM Line 5:20:25
相關用法
- VBScript Filter用法及代碼示例
- VBScript UCase用法及代碼示例
- VBScript InStrRev用法及代碼示例
- VBScript TimeValue用法及代碼示例
- VBScript UBound用法及代碼示例
- VBScript IsArray用法及代碼示例
- VBScript LBound用法及代碼示例
- VBScript Erase用法及代碼示例
- VBScript InStr用法及代碼示例
- VBScript Left用法及代碼示例
- VBScript DatePart用法及代碼示例
- VBScript IsDate用法及代碼示例
- VBScript Hour用法及代碼示例
- VBScript Right用法及代碼示例
- VBScript Mid用法及代碼示例
- VBScript WeekDayName用法及代碼示例
- VBScript Replace用法及代碼示例
注:本文由純淨天空篩選整理自 VBScript FormatDateTime Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。