A function of conversion time. The time processing in KINGCMS is also very powerful, you can take a look at it.
The date () function function in PHP is too powerful. I can't help but use ASP to imitate it ... but just write the day, not to write, minute, second ..
Therefore, this function has not been formatted for hours, in the second, second, and then add.
<%
'********************************
'Name: Time processing function
'Function: Formatdate (Str, Datetime)
'Parameters: Str Strings, DateTime Time
'Author: Xilou Lengyue
'Date: 2006/1/24
'URL: www.xilou.net | www.chinacms.org
'Description: The return type is a string, not the time type, the error returns false
'********************************
Function Formatdate (Str, Datetime)
Formatdate = false
If isdate (datetime) = false then
Formatdate = false
Exit function
End if
'// Years, Month, Week, Day, Hours, minutes, seconds
Dim y, m, w, d, h, min, s
'// The conversion of numbers and Chinese
Dim numtocn, cnstr
CNSTR = Zero | One | Two | Two | Four | Five | Six | Seven | Eight | Nine | Eleven | Twelve | 13 | Fourteen | Sixteen | Sixteen | 18 | 19 | Twenty |
CNSTR = CNSTR & Twenty -one | Twenty -three | Twenty -three | Twenty -four | Twenty -six | Twenty -six | Twenty -eight | Twenty -ninth | Thirty -one | Thirty -one |
CNSTR = CNSTR & Thirty -two | Thirty -three | Thirty -four | Thirty -six | Thirty -six | Thirty -eight | Thirty -eight | Forty Forty | Forty -two | Forty -two |
CNSTR = CNSTR & Forty -three | Forty -four | Forty -Fifth | Forty -six | Forty -seven | Forty -eight | Forty -nine | Fifty -one | Fifty -three | 53 | Fifty -three |
CNSTR = CNSTR & 54 | 55 | Fifty -six | Fifty -seven | 58 | Fifty -nine | Sixty
numtocn = Split (CNSTR, |)
'// The conversion of numbers and English
Dim numtoen, enstr
ENSTR = January | February | March | April | May | JULY | August | SEPTEMBER | October | November | December |
ENSTR = ENSTR & Sunday | Monday | TUESDAY | WEDNESDAY | Thursday | Friday | Saturday
numtoen = split (enstr, |)
'-----------------------------------------------------------------------------
'The process of the year, the time dateTime must include the year
'Tags: 3 {ya}: 2006 {yb}: 06 {yc}: 2006
Y = Year (Datetime) '
If Instr (Str, {ya})> 0 then str = replace (str, {ya}, y) '2006
If instr (str, {yb})> 0 then str = replace (str, {yb}, right (y, 2)) '06
If Instr (str, {yc})> 0 then
DIM YY 'Number and Chinese Conversion
Yy = y
For i = 0 to 9
Yy = replace (yy, i, numtocn (i))
Next
Str = Replace (Str, {yc}, yy) '2006
End if
'-----------------------------------------------------------------------------
'Monthly processing, time dateTime must include year and month
'Tags: 5 {ma}: 1 {mb}: 01 {mc}: a {md}: january {me}: jan
M = Month (datetime) 'Get the month
Dim mm
If instr (str, {ma})> 0 then str = replace (str, {ma}, m) '1
If Instr (Str, {mb})> 0 then
If m <10 thatn mm = 0 & m
Str = replace (str, {mb}, mm) '01
End if
'// Chinese January
If Instr (Str, {mc})> 0 then
Mm = m
For i = 1 to 12
If mm = I then mm = numtocn (i): exit for
Next
Str = replace (str, {mc}, mm) '
End if
'// English january
If Instr (Str, {md})> 0 then
Mm = m
For i = 1 to 12
If mm = I then mm = numtoen (i-1): exit for
Next
Str = replace (str, {md}, mm)
End if
'// English abbreviation jan
If instr (str, {me})> 0 then str = replace (str, {me}, left (mm, 3))
'----------------------------------------------------------------------------------------
'During the process, time dates must include the year of the year
'Tags: 4 {da}: 1 {db}: 01 {dc}: a {dd}: 1st
D = Day (datetime) '
DIM DD
'// Number 1
If instr (str, {da})> 0 then str = replace (str, {da}, d)
'// Number 01
If Instr (Str, {db})> 0 then
Dd = d
If dd <10 thatn dd = 0 & dd
Str = replace (str, {db}, dd)
End if
'// Chinese 1
If Instr (Str, {DC})> 0 THEN
Dd = d
For i = 1 to 31
If dd = I then dd = numtocn (i): exit for
Next
Str = replace (str, {dc}, dd)
End if
'// English 24th
If Instr (str, {dd})> 0 then
Dd = d
Select Case DD
Case 1, 21, 31
DD = DD & ST
Case 2, 22
DD = DD & ND
Case 3, 23
DD = DD & RD
Case Else
DD = DD & Th
End select
Str = replace (str, {dd}, dd)
End if
'----------------------------------------------------------------------------------------
'Sweetable, time DateTime must include the year of the year
'Tags: 4 {wa}: 1 {wb}: Friday {wc}: {wd}: tue
W = Weekday (dough)
Dim ww
'// Number 5
If instr (str, {wa})> 0 then str = replace (str, {wa}, w)
'// English Friday
If Instr (str, {wb})> 0 then
For i = 1 to 7
If w = I then str = replace (str, {wb}, numtoen (i+11)): exit for
Next
End if
'// Chinese five
If Instr (Str, {wc})> 0 then
Ww = w
If ww = 1 then
Str = replace (str, {wc}, day)
Else
For i = 2 to 7
If ww = I then str = replace (str, {wc}, numtocn (i-1)): exit for
Next
End if
End if
'// English abbreviation TUE
If Instr (Str, {wd})> 0 then
For i = 1 to 7
If w = I then str = replace (str, {wd}, left (numtoen (i+11), 3)): exit for
Next
End if
'----------------------------------------------------------------------------------------
'Hours of processing, time dateTime must include hours
'Label:
H = Hour (datetime)
Dim Hh
Formatdate = STR
End function
%>
<%
'example
'Sub br ()
'Response.write <br/> & vbcrf
'END SUB
'Sub Out (STR)
'Response.write Str & VBCRLF
'Br
'END SUB
'----------- test
'Dim s, t
'S = this year is {yc} Year of {yb} year {ya} year {ma} month {mb} month {mc} month {md} {me} {da} day {db} day the {dd day dd } Week {wb} | {wd} Week {wc}
'T = now ()
'OUT FORMATDATE (s, T)
%>