最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp 时间日期格式化程序
时间:2010-03-19 编辑:简简单单 来源:一聚教程网
'函数名:FormatTime
'作 用:时间格式化
'参 数:DateTime ----要格式化的时间
' Format ----格式的形式
'****************************************************
Public Function FormatTime(DateTime,Format)
select case Format
case "1"
FormatTime=""&year(DateTime)&"年"&month(DateTime)&"月"&day(DateTime)&"日"
case "2"
FormatTime=""&month(DateTime)&"月"&day(DateTime)&"日"
case "3"
FormatTime=""&year(DateTime)&"/"&month(DateTime)&"/"&day(DateTime)&""
case "4"
FormatTime=""&month(DateTime)&"/"&day(DateTime)&""
case "5"
FormatTime=""&month(DateTime)&"月"&day(DateTime)&"日"&FormatDateTime(DateTime,4)&""
case "6"
temp="周日,周一,周二,周三,周四,周五,周六"
temp=split(temp,",")
FormatTime=temp(Weekday(DateTime)-1)
case Else
FormatTime=DateTime
end select
End Function
Public Function TimeToDiff(DateTime)
If IsDate(DateTime) Then
Dim tSecond:tSecond=DateDiff("s",DateTime,Now())
If tSecond<60 Then'//一分钟内
TimeToDiff="刚刚"
End If
If tSecond>=60 And tSecond<3600 Then'//一小时内
TimeToDiff=DateDiff("n",DateTime,Now())&"分钟前"
End If
If tSecond>=3600 And tSecond<86400 Then'//一天内
TimeToDiff=DateDiff("h",DateTime,Now())&"小时前"
End If
If tSecond>=86400 And tSecond<2592000 Then'//一个月内
TimeToDiff=DateDiff("d",DateTime,Now())&"天前"
End If
If tSecond>=2592000 And tSecond<31536000 Then'//一年内
TimeToDiff=DateDiff("m",DateTime,Now())&"个月前"
End If
If tSecond>=31536000 Then'//其它
TimeToDiff=DateDiff("yyyy",DateTime,Now())&"年前"
End If
Else
TimeToDiff="N天前"
End If
End Function
-
下一个: 计算页面执行时间
相关文章
- VBS 批量Ping的项目讲解 09-19
- 如何封装一个Ajax函数介绍 09-16
- ASP实现加法验证码方法 09-16
- ASP错误捕获的几种常规处理方法介绍 09-16
- ajax实现城市三级联动的代码介绍 09-16
- asp中获取日期为星期几的技巧 09-14