VBScript FormatDateTime function
FormatDateTime function and returns a valid expression of the date or time.
grammar
FormatDateTime(date,format)
参数 | 描述 |
---|---|
date | 必需。任何有效的日期表达式(比如 Date() 或者 Now())。 |
format |
可选。规定所使用的日期/时间格式的格式值。
可采用下面的值:
|
Examples
Examples
Display the date in different formats:
<script type="text/vbscript">
d=CDate("2010-02-16 13:45")
document.write(FormatDateTime(d) & "<br />")
document.write(FormatDateTime(d,1) & "<br />")
document.write(FormatDateTime(d,2) & "<br />")
document.write(FormatDateTime(d,3) & "<br />")
document.write(FormatDateTime(d,4) & "<br />")
</script>
d=CDate("2010-02-16 13:45")
document.write(FormatDateTime(d) & "<br />")
document.write(FormatDateTime(d,1) & "<br />")
document.write(FormatDateTime(d,2) & "<br />")
document.write(FormatDateTime(d,3) & "<br />")
document.write(FormatDateTime(d,4) & "<br />")
</script>
Examples of the above output:
2/16/2010 1:45:00 PM
Tuesday, February 16, 2010
2/16/2010
1:45:00 PM
13:45
Tuesday, February 16, 2010
2/16/2010
1:45:00 PM
13:45
try it"
Complete VBScript Reference