我的資料庫中以<%=rs("selldate")%>讀取日期后,
在頁面上顯示的是這個樣式 yyyy/mm/dd 如何轉換成 yyyy-mm-dd
和 yyyy-mm-dd hh:mm:ss 這二個格式,代碼給如何寫,
也就是需要得到的是2020-10-26 和 2020-10-26 13:45:54 這二種
<%=FormatDateTime(rs("selldate"),1)%> 這個轉換不了我要的樣式。望老師們給個詳細代碼。感謝!
uj5u.com熱心網友回復:
a = '1995/11/11'
b = a.replace(/\//g, '-')
console.log(b)
// 1995-11-11
uj5u.com熱心網友回復:
response.write formatdate(selldate,"y-m-d")
response.write formatdate(selldate,"y-m-d h:n:s")
Function formatdate(byval sdate,byval stype)
Dim y,m,d,h,n,s,otime
y = Year(sdate)
m = right("00" & Month(sdate),2)
d = right("00" & Day(sdate),2)
h = right("00" & Hour(sdate),2)
n = right("00" & Minute(sdate),2)
s = right("00" & Second(sdate),2)
otime = stype
otime = Replace(otime,"timestamp",DateDiff("s","1970-01-01 08:00:00",sdate))
otime = Replace(otime,"y",y)
otime = Replace(otime,"m",m)
otime = Replace(otime,"d",d)
otime = Replace(otime,"h",h)
otime = Replace(otime,"n",n)
otime = Replace(otime,"s",s)
formatdate = otime
End Function
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/193275.html
標籤:ASP
