asp 换算日期问题

来源:百度知道 编辑:UC知道 时间:2024/05/23 00:16:52
将当前日期与数据库日期对比,换算出如:"今天","昨天","5天前","2个月前"等这样的格式.
有现成的类最好~!

100分等着~!

先谢过啦~!

<%
dim d,databasedate
databasedate= '日期你自己从数据库里提取
d=date()-databasedate
if d=0 then
response.write "今天"
elseif d=1 then
response.write "昨天"
elseif d<5 then
response.write d & "天之前"
elseif d>5 and d<60 then
response.write "5天前"
esleif d>60 then
response.write "两个月前"
end if
%>

<% d1=rs("date") '数据库中的时间
d2= date() '当前时间
dd=datediff("d",d1 ,d2) '两者的差
if dd=0 then%>
今天
<%elseif dd=-1 then%> 昨天
<%elseif dd=-5 then%> 5天前
..............(类似,省略)
<% end if %>

给我算了
反正没人说
我还需要几分
以后再还了你