Home > front end >  Read from the data date yyyy/mm/dd how to convert - dd yyyy - mm
Read from the data date yyyy/mm/dd how to convert - dd yyyy - mm

Time:10-27

I database to & lt; %=rs (" selldate ") % & gt; Read after the date,
Displayed on the page is the style of yyyy/mm/dd how to convert - dd yyyy - mm
And mm - dd yyyy - hh: mm: ss these two formats, to how to write code,
Is the need to get the 2020-10-26 and 2020-10-26 13:45:54 these two

& lt; %=FormatDateTime (rs (" selldate "), 1) % & gt; This conversion is not the style I want, hope the teachers give a detailed code, thank you!

CodePudding user response:

 a='1995/11/11' 
B=a.r eplace (////g, '-')
The console. The log (b)
//the 1995-11-11

CodePudding user response:

 
Response. Write formatdate (selldate, "y -m - d")
Response. Write formatdate (selldate, "y -m - d h: n: s")
The Function formatdate (byval sdate, byval stype)
Dim y, m, d, h, n, s, otime
Y=Year (sdate)
M=right (" 00 "& amp; The Month (sdate), 2)
D=right (" 00 "& amp; Day (sdate), 2)
H=right (" 00 "& amp; Hour (sdate), 2)
N=right (" 00 "& amp; Minute (sdate), 2)
S=right (" 00 "& amp; The Second (sdate), 2)
Otime=stype
Otime=Replace (otime, timestamp, DateDiff (" s ", "the 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 the Function
  •  Tags:  
  • ASP
  • Related