查看: 146  |  回复: 0
  ASP fmtdate(sdate)格式化日期:2001-01-01 fmttime(stime)格式化时间:08:01:01
楼主
发表于 2024年5月28日 14:54
<%
'格式化日期:2001-01-01
function fmtdate(sdate)
    dim monstr,daystr

    if month(sdate)<10 then
        monstr="0" & month(sdate)
    else
        monstr=month(sdate)
    end if
   
    if day(sdate)<10 then
        daystr="0" & day(sdate)
    else
        daystr=day(sdate)
    end if
    fmtdate=year(sdate) & "-" & monstr & "-" & daystr
end function

'格式化时间:08:01:01
function fmttime(stime)
    dim houstr,minstr,secstr

    if hour(stime)<10 then
        houstr="0" & hour(stime)
    else
        houstr=hour(stime)
    end if
   
    if Minute(stime)<10 then
        minstr="0" & Minute(stime)
    else
        minstr=Minute(stime)
    end if
   
    if Second(stime)<10 then
        secstr="0" & Second(stime)
    else
        secstr=Second(stime)
    end if
       
    fmttime=houstr & ":" & minstr & ":" & secstr
end function

response.write fmtdate(date) & " " & fmttime(time)
%>

运行结果:

2024-05-28 14:54:30

您需要登录后才可以回帖 登录 | 立即注册
【本版规则】请勿发表违反国家法律的内容,否则会被冻结账号和删贴。
用户名: 立即注册
密码:
2020-2024 MaNongKu.com