Har gjort en liknande funktion: http://www.webeye.nu/default2.asp?que=asp/format.asp
Dock är det ganska mycket mer kod, men innehåller lite fler "funktioner". ;)
Mvh, Vide
1 svar · 1 101 visningar · startad av Erik Juhlin
Ett försök till att göra datumformatering lite enklare. Har härmat Format funktionen i VB. :)
<%
Function Format(dDate, sFormat)
dDate = CDate(dDate)
sFormat = Replace(sFormat, "YYYY", Right("0000" & Year(dDate), 4), 1, -1, 1)
sFormat = Replace(sFormat, "MM", Right("00" & Month(dDate), 2), 1, -1, 1)
sFormat = Replace(sFormat, "M", Month(dDate), 1, -1, 1)
sFormat = Replace(sFormat, "DD", Right("00" & Day(dDate), 2), 1, -1, 1)
sFormat = Replace(sFormat, "D", Day(dDate), 1, -1, 1)
sFormat = Replace(sFormat, "HH", Right("00" & Hour(dDate), 2), 1, -1, 1)
sFormat = Replace(sFormat, "H", Hour(dDate), 1, -1, 1)
sFormat = Replace(sFormat, "NN", Right("00" & Minute(dDate), 2), 1, -1, 1)
sFormat = Replace(sFormat, "N", Minute(dDate), 1, -1, 1)
sFormat = Replace(sFormat, "SS", Right("00" & Second(dDate), 2), 1, -1, 1)
sFormat = Replace(sFormat, "S", Second(dDate), 1, -1, 1)
Format = sFormat
End Function
Response.Write Format(Now, "YYYY-MM-DD HH:NN:SS.000") & "<br>"
Response.Write Format(Now, "H:NN - D / M, YYYY") & "<br>"
Response.Write Format(Now, "Kl. HH:NN:SS") & "<br>"
%>
Har gjort en liknande funktion: http://www.webeye.nu/default2.asp?que=asp/format.asp
Dock är det ganska mycket mer kod, men innehåller lite fler "funktioner". ;)
Mvh, Vide