- VBScript 教程
- VBScript - 主頁
- VBScript - 概覽
- VBScript - 語法
- VBScript - 啟用
- VBScript - 位置
- VBScript - 變數
- VBScript - 常量
- VBScript - 運算子
- VBScript - 決策
- VBScript - 迴圈
- VBScript - 事件
- VBScript - Cookie
- VBScript - 數字
- VBScript - 字串
- VBScript - 陣列
- VBScript - 日期
- 高階 VBScript
- VBScript - 過程
- VBScript - 對話方塊
- VBScript - 面向物件
- VBScript - 正則表示式
- VBScript - 錯誤處理
- VBScript - 雜項語句
- VBScript 有用資源
- VBScript - 問題和答案
- VBScript - 快速指南
- VBScript - 有用資源
- VBScript - 討論
VBScript FormatDateTime 函式
這是一個函式,可幫助開發人員設定和返回有效的日期時間表達式。
語法
FormatDateTime(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_date.htm
廣告