极乐门资源网 Design By www.ioogu.com
论坛里又有人问起日期怎样格式化为:2004-08-09 05:02:20这样的格式:于是写了一个左(右)对齐的函数.这函数等价于.NET里String对象的PadLeft和PadRight函数
Function PadLeft(Value,Length,sChar) Dim strText,I strText = String(Length,sChar) strText = strText & Value LeftPad = Right(strText,Length) End Function
改一下最下面则为这样:
Function PadRight(Value,Length,sChar) Dim strText,I strText = String(Length,sChar) strText = Value & strText LeftPad = Left(strText,Length) End Function
使用例子:日期显示
AA = year(now) & "-" & PadLeft(month(now),2,"0") & "-" & PadLeft(Day(now),2,"0") & " " & PadLeft(Hour(now),2,"0") & ":" & PadLeft(Minute(now),2,"0") & ":" & PadLeft(Second(now),2,"0")
万能时间补位代码
Public Function ForMatDate(DateAndTime, Para) '格式化日期(日期时间,格式) Dim Y, M, D, H, F, S IF Not ISNumeric(Para) Or Not ISDate(DateAndTime) Then Exit Function Y = CStr(Year(DateAndTime)) M = CStr(Month(DateAndTime)):IF Len(M) = 1 Then M = "0" & M D = CStr(Day(DateAndTime)):IF Len(D) = 1 Then D = "0" & D H = CStr(Hour(DateAndTime)):IF Len(H) = 1 Then H = "0" & H F = CStr(Minute(DateAndTime)):IF Len(F) = 1 Then F = "0" & F S = CStr(Second(DateAndTime)):IF Len(S) = 1 Then S = "0" & S Select Case Para Case "0" ForMatDate = Y & "-" & M & "-" & D & " " & H & ":" & F & ":" & S Case "1" ForMatDate = Y & "-" & M & "-" & D & " " & H & ":" & F Case "2" ForMatDate = Y & "-" & M & "-" & D Case "3" ForMatDate = Y & "/" & M & "/" & D Case "4" ForMatDate = Y & "年" & M & "月" & D & "日" Case "5" ForMatDate = M & "-" & D & " " & H & ":" & F Case "6" ForMatDate = M & "/" & D Case "7" ForMatDate = M & "月" & D & "日" Case "8" ForMatDate = Y & "年" & M & "月" Case "9" ForMatDate = Y & "-" & M Case "10" ForMatDate = Y & "/" & M Case "11" ForMatDate = right(Y,2) & "-" &M & "-" & D & " " & H & ":" & F Case "12" ForMatDate = right(Y,2) & "-" &M & "-" & D Case "13" ForMatDate = M & "-" & D Case Else ForMatDate = DateAndTime End Select End Function Response.Write ForMatDate(Now,"2")
asp一段自动补位的函数
function formatsn(getnum,getbit) dim formatsnnum,formatsnpre,formatsnj formatsnnum = getbit – len(getnum) for formatsnj = 1 to formatsnnum formatsnpre = formatsnpre & "0" next formatsn = formatsnpre & getnum end function
使用方法
formatsn(getnum,getbit)
getnum 计数
getbit 共几位
极乐门资源网 Design By www.ioogu.com
极乐门资源网
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
极乐门资源网 Design By www.ioogu.com
暂无ASP中实现字符部位类似.NET里String对象的PadLeft和PadRight函数的评论...
更新日志
2024年12月25日
2024年12月25日
- 小骆驼-《草原狼2(蓝光CD)》[原抓WAV+CUE]
- 群星《欢迎来到我身边 电影原声专辑》[320K/MP3][105.02MB]
- 群星《欢迎来到我身边 电影原声专辑》[FLAC/分轨][480.9MB]
- 雷婷《梦里蓝天HQⅡ》 2023头版限量编号低速原抓[WAV+CUE][463M]
- 群星《2024好听新歌42》AI调整音效【WAV分轨】
- 王思雨-《思念陪着鸿雁飞》WAV
- 王思雨《喜马拉雅HQ》头版限量编号[WAV+CUE]
- 李健《无时无刻》[WAV+CUE][590M]
- 陈奕迅《酝酿》[WAV分轨][502M]
- 卓依婷《化蝶》2CD[WAV+CUE][1.1G]
- 群星《吉他王(黑胶CD)》[WAV+CUE]
- 齐秦《穿乐(穿越)》[WAV+CUE]
- 发烧珍品《数位CD音响测试-动向效果(九)》【WAV+CUE】
- 邝美云《邝美云精装歌集》[DSF][1.6G]
- 吕方《爱一回伤一回》[WAV+CUE][454M]