asp格式时间的函数
2006-05-15 10:34
302 查看
<%Response.Expires = 0%>
<%
function FormatDate(sStr,sFormat,sChar)
if sStr = "" or not isdate(sStr) or sChar="" then
'Response.Write "NULL"
FormatDate = ""
exit function
end if
dim sYear,sMonth,sDay,sHour,sMinute,sSecond
sYear = year(sStr)
if len(sYear)< 4 then sYear ="20" & sYear
sMonth = month(sStr)
if clng(sMonth)<10 and len(sMonth)<2 then sMonth = "0" & sMonth
sDay = day(sStr)
if clng(sDay)<10 and len(sDay)<2 then sDay = "0" & sDay
sHour = hour(sStr)
if clng(sHour)<10 and len(sHour)<2 then sHour = "0" & sHour
sMinute = Minute(sStr)
if clng(sMinute)<10 and len(sMinute)<2 then sMinute = "0" & sMinute
sSecond = Second(sStr)
if clng(sSecond)<10 and len(sSecond)<2 then sSecond = "0" & sSecond
select case ucase(sFormat)
case "YYYYMM"
FormatDate = sYear & sChar & sMonth
case "YYYYMMDD"
FormatDate = sYear & sChar & sMonth & sChar & sDay
case "YYYYMM@"
FormatDate = sYear & "Äê" & sMonth & "ÔÂ"
case "YYYYMMDD@"
FormatDate = sYear & "Äê" & sMonth & "ÔÂ" & sDay & "ÈÕ"
case "YYYYMMDDHHMMSS_NULL"
FormatDate = sYear & sMonth & sDay & sHour & sMinute & sSecond
case "YYYYMMDDHHMMSS"
FormatDate = sYear & sChar & sMonth & sChar & sDay & " " & sHour & ":" & sMinute
case "YYYYMMDDHHMM"
FormatDate = sYear & sChar & sMonth & sChar & sDay & " " & sHour & ":" & sMinute
case "YYYYMMDDHHMMSS@"
FormatDate = sYear & "Äê" & sMonth & "ÔÂ" & sDay & "ÈÕ" & sHour & "ʱ" & sMinute & "·Ö" & sSecond & "Ãë"
case else
formatDate = sStr
end select
end function
function getTextarea(sStr)
if sStr = "" then
sStr = ""
else
sStr = Replace(Replace(sStr,chr(10),"<br>"),chr(32)," ")
end if
getTextarea = sStr
end function
function getTextareatodb(sStr)
if sStr = "" then
sStr = ""
else
sStr = Replace(Replace(sStr,chr(10),"<br>"),chr(32)," ")
end if
getTextareatodb = sStr
end function
function DeTextarea(sStr)
if sStr = "" then
sStr = ""
else
sStr = Replace(Replace(sStr,"<br>",chr(10))," ",chr(32))
end if
DeTextarea = sStr
end function
function pub_getMemoValue(sStr)
dim s_str
s_str = sStr
if s_str = "" or isnull(s_str) then
pub_getMemoValue = " "
else
pub_getMemoValue = rtrim(s_str)
end if
end function
function pub_getMemoValue_sub(sStr,sLen)
dim s_str
s_str = sStr
if s_str = "" or isnull(s_str) then
pub_getMemoValue_sub = " "
else
if len(s_str)>sLen then
pub_getMemoValue_sub = rtrim(mid(s_str,1,sLen)) & "..."
else
pub_getMemoValue_sub = rtrim(s_str)
end if
end if
end function
%>
<%
function FormatDate(sStr,sFormat,sChar)
if sStr = "" or not isdate(sStr) or sChar="" then
'Response.Write "NULL"
FormatDate = ""
exit function
end if
dim sYear,sMonth,sDay,sHour,sMinute,sSecond
sYear = year(sStr)
if len(sYear)< 4 then sYear ="20" & sYear
sMonth = month(sStr)
if clng(sMonth)<10 and len(sMonth)<2 then sMonth = "0" & sMonth
sDay = day(sStr)
if clng(sDay)<10 and len(sDay)<2 then sDay = "0" & sDay
sHour = hour(sStr)
if clng(sHour)<10 and len(sHour)<2 then sHour = "0" & sHour
sMinute = Minute(sStr)
if clng(sMinute)<10 and len(sMinute)<2 then sMinute = "0" & sMinute
sSecond = Second(sStr)
if clng(sSecond)<10 and len(sSecond)<2 then sSecond = "0" & sSecond
select case ucase(sFormat)
case "YYYYMM"
FormatDate = sYear & sChar & sMonth
case "YYYYMMDD"
FormatDate = sYear & sChar & sMonth & sChar & sDay
case "YYYYMM@"
FormatDate = sYear & "Äê" & sMonth & "ÔÂ"
case "YYYYMMDD@"
FormatDate = sYear & "Äê" & sMonth & "ÔÂ" & sDay & "ÈÕ"
case "YYYYMMDDHHMMSS_NULL"
FormatDate = sYear & sMonth & sDay & sHour & sMinute & sSecond
case "YYYYMMDDHHMMSS"
FormatDate = sYear & sChar & sMonth & sChar & sDay & " " & sHour & ":" & sMinute
case "YYYYMMDDHHMM"
FormatDate = sYear & sChar & sMonth & sChar & sDay & " " & sHour & ":" & sMinute
case "YYYYMMDDHHMMSS@"
FormatDate = sYear & "Äê" & sMonth & "ÔÂ" & sDay & "ÈÕ" & sHour & "ʱ" & sMinute & "·Ö" & sSecond & "Ãë"
case else
formatDate = sStr
end select
end function
function getTextarea(sStr)
if sStr = "" then
sStr = ""
else
sStr = Replace(Replace(sStr,chr(10),"<br>"),chr(32)," ")
end if
getTextarea = sStr
end function
function getTextareatodb(sStr)
if sStr = "" then
sStr = ""
else
sStr = Replace(Replace(sStr,chr(10),"<br>"),chr(32)," ")
end if
getTextareatodb = sStr
end function
function DeTextarea(sStr)
if sStr = "" then
sStr = ""
else
sStr = Replace(Replace(sStr,"<br>",chr(10))," ",chr(32))
end if
DeTextarea = sStr
end function
function pub_getMemoValue(sStr)
dim s_str
s_str = sStr
if s_str = "" or isnull(s_str) then
pub_getMemoValue = " "
else
pub_getMemoValue = rtrim(s_str)
end if
end function
function pub_getMemoValue_sub(sStr,sLen)
dim s_str
s_str = sStr
if s_str = "" or isnull(s_str) then
pub_getMemoValue_sub = " "
else
if len(s_str)>sLen then
pub_getMemoValue_sub = rtrim(mid(s_str,1,sLen)) & "..."
else
pub_getMemoValue_sub = rtrim(s_str)
end if
end if
end function
%>
相关文章推荐
- 详细介绍asp.net获取日期时间的各种格式的函数
- ASP.NET时间函数及其格式转换
- asp.net 时间格式大全
- Asp利用DateAdd 函数进行时间相加计算问题
- ASP.NET时间函数及其格式转换
- asp之日期和时间函数示例
- Asp.Net日期时间格式设置
- ASP中date()取系统时间格式
- asp.net GridView 时间格式化 设置 短日期格式 去掉0!
- ASP.NET C# 日期 时间 年 月 日 时 分 秒 格式及转换(转自happymagic的专栏)
- asp.net DateTime 时间函数
- asp.net 时间显示格式
- asp中日期时间函数介绍
- C#时间格式大全(转)/时间函数大全
- ASP日期函数与时间函数的详细说明
- Asp.Net日期时间格式设置
- ASP.NET时间函数及其格式转换
- 封装my97时间控件成asp.net 时间控件,支持多语言,皮肤,时间大小限制,时间格式验证功能,非常强大。
- ASP 格式化时间函数