ASP日期转换
<%=date()%>这个日期显示的是:2013-7-3怎么让他显示成为:2013-07-03本人菜鸟,请帮我写个代码,直接复制的吧,呵呵,万份感谢...
<%=date()%>
这个日期显示的是:2013-7-3
怎么让他显示成为:2013-07-03
本人菜鸟,请帮我写个代码,直接复制的吧,呵呵,万份感谢 展开
这个日期显示的是:2013-7-3
怎么让他显示成为:2013-07-03
本人菜鸟,请帮我写个代码,直接复制的吧,呵呵,万份感谢 展开
2个回答
展开全部
<%
'20110301增加日期格式化函数
' ============================================
' 格式化时间(显示)
' 参数:n_Flag
' 1:"yyyy-mm-dd hh:mm:ss"
' 2:"yyyy-mm-dd"
' 3:"hh:mm:ss"
' 4:"yyyy年mm月dd日"
' 5:"yyyymmdd"
' 6:"yyyymmddhhmmss"
' ============================================
Function Format_Time(s_Time, n_Flag)
Dim y, m, d, h, mi, s
Format_Time = ""
If IsDate(s_Time) = False Then Exit Function
y = cstr(year(s_Time))
m = cstr(month(s_Time))
If len(m) = 1 Then m = "0" & m
d = cstr(day(s_Time))
If len(d) = 1 Then d = "0" & d
h = cstr(hour(s_Time))
If len(h) = 1 Then h = "0" & h
mi = cstr(minute(s_Time))
If len(mi) = 1 Then mi = "0" & mi
s = cstr(second(s_Time))
If len(s) = 1 Then s = "0" & s
Select Case n_Flag
Case 1
' yyyy-mm-dd hh:mm:ss
Format_Time = y & "-" & m & "-" & d & " " & h & ":" & mi & ":" & s
Case 2
' yyyy-mm-dd
Format_Time = y & "-" & m & "-" & d
Case 3
' hh:mm:ss
Format_Time = h & ":" & mi & ":" & s
Case 4
' yyyy年mm月dd日
Format_Time = y & "年" & m & "月" & d & "日"
Case 5
' yyyymmdd
Format_Time = y & m & d
case 6
'yyyymmddhhmmss
format_time= y & m & d & h & mi & s
case 7
format_time= y
case 8
format_time= m
case 9
format_time= d
End Select
End Function
response.write Format_Time(date(), 2)
%>
'20110301增加日期格式化函数
' ============================================
' 格式化时间(显示)
' 参数:n_Flag
' 1:"yyyy-mm-dd hh:mm:ss"
' 2:"yyyy-mm-dd"
' 3:"hh:mm:ss"
' 4:"yyyy年mm月dd日"
' 5:"yyyymmdd"
' 6:"yyyymmddhhmmss"
' ============================================
Function Format_Time(s_Time, n_Flag)
Dim y, m, d, h, mi, s
Format_Time = ""
If IsDate(s_Time) = False Then Exit Function
y = cstr(year(s_Time))
m = cstr(month(s_Time))
If len(m) = 1 Then m = "0" & m
d = cstr(day(s_Time))
If len(d) = 1 Then d = "0" & d
h = cstr(hour(s_Time))
If len(h) = 1 Then h = "0" & h
mi = cstr(minute(s_Time))
If len(mi) = 1 Then mi = "0" & mi
s = cstr(second(s_Time))
If len(s) = 1 Then s = "0" & s
Select Case n_Flag
Case 1
' yyyy-mm-dd hh:mm:ss
Format_Time = y & "-" & m & "-" & d & " " & h & ":" & mi & ":" & s
Case 2
' yyyy-mm-dd
Format_Time = y & "-" & m & "-" & d
Case 3
' hh:mm:ss
Format_Time = h & ":" & mi & ":" & s
Case 4
' yyyy年mm月dd日
Format_Time = y & "年" & m & "月" & d & "日"
Case 5
' yyyymmdd
Format_Time = y & m & d
case 6
'yyyymmddhhmmss
format_time= y & m & d & h & mi & s
case 7
format_time= y
case 8
format_time= m
case 9
format_time= d
End Select
End Function
response.write Format_Time(date(), 2)
%>
展开全部
判断一下月日就行了
<%=year(date())%>-<%
if len(Month(date()))>=2 then
response.Write Month(date())
else
response.Write "0"&Month(date())
end if %>-<%
if len(day(date()))>=2 then
response.Write day(date())
else
response.Write "0"&day(date())
end if %>
<%=year(date())%>-<%
if len(Month(date()))>=2 then
response.Write Month(date())
else
response.Write "0"&Month(date())
end if %>-<%
if len(day(date()))>=2 then
response.Write day(date())
else
response.Write "0"&day(date())
end if %>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询