DoDateTime 显示时间格式求助!! ASP

来源:百度知道 编辑:UC知道 时间:2024/06/30 02:39:19
<%= DoDateTime((Torrent.Fields.Item("Torrent_Time").Value), 1, -1) %>

如何让时间 只显示月份?? 如“9月2日”显示为“09”;只显示日期如“02”呢?

ASP

DoDateTime不是内置的默认函数。所以我不知道你那个是什么。

按照你段代码,可以判断
Torrent.Fields.Item("Torrent_Time").Value 是一个完整日期
比如 “2008-12-31”

你可以用year(),month(),day(),weekday()这几个内置函数。

只显示月份就:<%=month(Torrent.Fields.Item("Torrent_Time").Value)%>

只显示几号就:<%=day(Torrent.Fields.Item("Torrent_Time").Value )%>

自己还可以组合一下:<%=month(Torrent.Fields.Item("Torrent_Time").Value)&"月"&day(Torrent.Fields.Item("Torrent_Time").Value &"号"%>
这样就能获得 10月12号 这样的显示
(代码&可能会被zhidao过滤出一个斜杠)

<%
Dim Month,Day
Month=Month(Now())
Day=Day(Now())
If Len(Month)=1 Then Month="0"&Month
If Day(Month)=1 Then Day="0"&Day
Response.Write Month&"月"&Day&"号"
%>