凤来仪

专业的计算机学习网站

首页 > ASP日期时间补0

ASP日期时间补0

点击:1862 发布时间:

    ASP中输出日期时间时,月、日、时、分、秒,有时是两位数,有时是一位数。在网页排版时会显得不齐整,影响美观。

    本文提供两个小函数,使得输出日期时间时,不足两位数的月、日、时、分、秒能够自动补0。

'ASP日期补零函数
Function FStime(times)
    Dim years,months,days
    if not isdate(times) then exit function
    years=year(times)
    months=right("0"&month(times),2)
    days=right("0"&day(times),2)
    times=years&"-"&months&"-"&days
    FStime=times
End Function

Function FLtime(times)
'ASP时间补零函数
    Dim years,months,days,hours,minutes,seconds
    if not isdate(times) then exit function
    years=year(times)
    months=right("0"&month(times),2)
    days=right("0"&day(times),2)
    hours=right("0"&hour(times),2)
    minutes=right("0"&minute(times),2)
    seconds=right("0"&second(times),2)
    FLtime=years&"-"&months&"-"&days&" "&hours&":"&minutes&":"&seconds
End Function