一个关于format函数的问题

muwenyi 2001-07-27 10:54:07

<%=format("9:59","hh:mm:ss")%>在调试中为什么报错(format格式不匹配)

VB中的format函数能不能在ASP程序中使用?
...全文
135 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
muwenyi 2001-07-27
  • 打赏
  • 举报
回复
在系统的区域设置中我将时间格式设置为hh:mm:ss。
为什么语句<%=formatDateTime("9:29:13",3)%>显示的输出结果是9:29:13呢?
按照参数显示结果应该为09:29:13呀!
我使用的操作系统是WIN2000,这个问题与操作系统问题有关吗?
我希望得到六位的时间输出结果,因为这样用户界面才美观整齐。请指教!
jinjinxy 2001-07-27
  • 打赏
  • 举报
回复
在VBScript函数中没有Format函数,请使用FormatDateTime函数
格式如下 FormatDateTime(Date[, NamedFormat])
The NamedFormat argument has the following settings:

Constant Value Description
vbGeneralDate 0 Display a date and/or time. If there is a date part, display it as a short date. If there is a time part, display it as a long time. If present, both parts are displayed.
vbLongDate 1 Display a date using the long date format specified in your computer's regional settings.
vbShortDate 2 Display a date using the short date format specified in your computer's regional settings.
vbLongTime 3 Display a time using the time format specified in your computer's regional settings.
vbShortTime 4 Display a time using the 24-hour format
孟子E章 2001-07-27
  • 打赏
  • 举报
回复
FormatDateTime()
muwenyi 2001-07-27
  • 打赏
  • 举报
回复
使用second()函数,显示还是有问题。如果时间是8:12:32的话显示没有问题,显示结果为:08:12:32。但如果时间为8:12:03的话,就会显示错误,显示结果为:08:12:3。也就是不能显示成“03”,哎~~~~~~~~~!(我的区域设置中的时间格式设置为:hh:mm:ss)
muwenyi 2001-07-27
  • 打赏
  • 举报
回复
小妹的错误就在于编写程序的时候不是很灵活,认死一条道就不知道融会贯通了,谢谢各位专家的指导和帮忙。
mvp2000 2001-07-27
  • 打赏
  • 举报
回复
楼上写的对

VB和ASP的函数不是完全一样的!
muwenyi 2001-07-27
  • 打赏
  • 举报
回复
to jdxx
您的方法使我解决了这个问题,非常感谢您的帮助。
jdxx 2001-07-27
  • 打赏
  • 举报
回复
=formatDateTime(now,4)&" :"&second(now) 即可。

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧