Because the short date is less than 2 digits, it affects the beauty when typing web pages. The following two functions can solve this problem.
2020-2-7 Short date changes 2020-02-07 Long date
Function FStime(times) Dim years,months,days if len(times)=0 then exit function years=year(times) months=right("0"&month(times),2) days=right("0"&day(times),2) times=years&"-"&months&"-"&days FStime=timesEnd Function2020-2-7 23:37:5 Short date changes 2020-02-07 23:37:05 Long date
Function FLtime(times) Dim years,months,days,hours,minutes,seconds if len(times)=0 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&":"&secondsEnd FunctionPw_Sys date format conversion function
<%Rem Pw_Sys Date Format Conversion Function Function DateTimeFormat(DateTime,Format)select case Formatcase "1"DateTimeFormat=""&year(DateTime)&month(DateTime)&month(DateTime)&month"&Right("0" & Day(DateTime),2)&"day"case "2"DateTimeFormat=""&month(DateTime)&"month"&Right("0" & Day(DateTime),2)&"day"case "3"DateTimeFormat=""&year(DateTime)&"-"&month(DateTime)&"-"&Right("0" & Day(DateTime),2)&"""case "4"DateTimeFormat=""&year(DateTime)&"/"&month(DateTime)&"/"&Right("0" & Day(DateTime),2)&""case "5"DateTimeFormat=""&month(DateTime)&"/"&Right("0" & Day(DateTime),2)&""case "6"DateTimeFormat=""&year(DateTime)&month(DateTime)&"month"&Right("0" & Day(DateTime),2)&"day<font color=red> "&FormatDateTime(DateTime,4)&"</font>"case "7" temp="Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday" temp=split(temp,",") DateTimeFormat=temp(WeekRight("0" & Day(DateTime),2)-1)case "8"DateTimeFormat=""&month(DateTime)&"-"&Right("0" & Day(DateTime),2)&""case "9"if len(hour(DateTime)) = 1 thenstr="0"&hour(DateTime)elsestr=hour(DateTime)end ifDateTimeFormat=DateTimeFormat(DateTime,1)&" "&str&":"&Minute(DateTime)case "10"DateTimeFormat=""&year(DateTime)&"year"&month(DateTime)&"month"case elseDateTimeFormat=DateTimeend selectend function%>Program code (a method to convert months and dates in yyyy-mm-dd format into two digits)
dim today
today=Date 'Avoid repeated calls to Date, so assign values to a variable
today=Year(today) & "-" & Right("0" & Month(today),2) & "-" & Right("0" & Day(today),2)
A function that automatically fills up the position in asp
function formatsn(getnum,getbit)dim formatsnnum,formatsnpre,formatsnjformatsnnum = getbit – len(getnum)for formatsnj = 1 to formatsnnumformatsnpre = formatsnpre & "0"nextformatsn = formatsnpre & getnumend function