- 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
广告