请选择 进入手机版 | 继续访问电脑版
查看: 407|回复: 0

[.NET开发] ASP 运算时间的函数

3万

主题

3万

帖子

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
100197
发表于 2015-11-23 17:52:14
例如:

[Java]JDOM解析XML字符串(非XML文档) 1小时前 By YuChao
[CSS]实现左中右三列布局 4小时前 By 红薯

ASP实现也很简单
  1. '算天数小时函数
  2. function diffuudate(logdate)
  3. if datediff("n",logdate,now())<60 then
  4. diffuudate = "<font color=red>"&datediff("n",logdate,now())&"分钟前</font>"
  5. elseif datediff("h",logdate,now())<24 then
  6. diffuudate = "<font color=blue>"&datediff("h",logdate,now())&"小时前</font>"
  7. elseif datediff("d",logdate,now())<31 then
  8. diffuudate = "<font color=#444>"&datediff("d",logdate,now())&"天前</font>"
  9. elseif datediff("m",logdate,now())<12 then
  10. if datediff("m",logdate,now())=6 then
  11. diffuudate = "<font color=#888>半年前</font>"
  12. else
  13. diffuudate = "<font color=#aaa>"&datediff("m",logdate,now())&"月前</font>"
  14. end if
  15. elseif datediff("yyyy",logdate,now())>0 then
  16. diffuudate = "<font color=#ccc>"&datediff("yyyy",logdate,now())&"年前</font>"
  17. end if
  18. end function
复制代码


回复

使用道具 举报