Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

VBScript FormatDateTime 函数


❮ VBScript 完整参考

FormatDateTime 函数格式化并返回有效的日期或时间表达式。

语法

FormatDateTime(date,format)

参数 描述
date 必需。任何有效的日期表达式(如 Date() 或 Now())
format 可选。指定要使用的日期/时间格式的值

可以取以下值

  • 0 = vbGeneralDate - 默认值。返回日期:mm/dd/yyyy 和时间(如果指定):hh:mm:ss PM/AM。
  • 1 = vbLongDate - 返回日期:星期几,月份,年份
  • 2 = vbShortDate - 返回日期:mm/dd/yyyy
  • 3 = vbLongTime - 返回时间:hh:mm:ss PM/AM
  • 4 = vbShortTime - 返回时间:hh:mm

示例

示例

以不同的格式显示日期

<%

d=CDate("2019-05-31 13:45")
response.write(FormatDateTime(d) & "<br />")
response.write(FormatDateTime(d,1) & "<br />")
response.write(FormatDateTime(d,2) & "<br />")
response.write(FormatDateTime(d,3) & "<br />")
response.write(FormatDateTime(d,4) & "<br />")

%>

以上代码的输出将是

5/31/2019 1:45:00 PM
2019年5月31日,星期五
5/31/2019
1:45:00 PM
13:45
显示示例 »

❮ VBScript 完整参考
×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.