• ASP 格式化显示时间为几个月,几天前,几小时前,几分钟前,或几秒前


    实现函数代码
    Function DateStringFromNow(Byval sTheDate)
    ' 格式化显示时间为几个月,几天前,几小时前,几分钟前,或几秒前
    Dim iSeconds, iMinutes, iHours, iDays

    iSeconds
    = DateDiff("s", sTheDate, Now()) 'd/h/n/s
    iMinutes = Int(iSeconds/60)
    iHours
    = Int(iSeconds/3600)
    iDays
    = Int(iSeconds/86400)

    If iDays > 60 Then
    DateStringFromNow
    = sTheDate
    ElseIf iDays > 30 Then
    DateStringFromNow
    = "1个月前"
    ElseIf iDays > 14 Then
    DateStringFromNow
    = "2周前"
    ElseIf iDays > 7 Then
    DateStringFromNow
    = "1周前"
    ElseIf iDays > 1 Then
    DateStringFromNow
    = iDays & "天前"
    ElseIf iHours > 1 Then
    DateStringFromNow
    = iHours & "小时前"
    ElseIf iMinutes > 1 Then
    DateStringFromNow
    = iMinutes & "分钟前"
    ElseIf iSeconds >= 1 Then
    DateStringFromNow
    = iSeconds & "秒前"
    Else
    DateStringFromNow
    = "1秒前"
    End If
    End Function
  • 相关阅读:
    【k8s】Volume-persistentVolumeReclaimPolicy
    【k8s】Volume-pv
    【k8s】Secret-生成环境变量
    【k8s】Volume-nfs
    【k8s】Volume-hostPath
    【k8s】Volume-emptyDir
    【k8s】Volume-downwardAPI
    【k8s】Volume-Secret
    【k8s】Volume-ConfigMap-file
    SQL SERVER 列转行
  • 原文地址:https://www.cnblogs.com/wintalen/p/1904685.html
Copyright © 2020-2023  润新知