白云岛资源网 Design By www.pvray.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.pvray.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
白云岛资源网 Design By www.pvray.com
暂无评论...
P70系列延期,华为新旗舰将在下月发布
3月20日消息,近期博主@数码闲聊站 透露,原定三月份发布的华为新旗舰P70系列延期发布,预计4月份上市。
而博主@定焦数码 爆料,华为的P70系列在定位上已经超过了Mate60,成为了重要的旗舰系列之一。它肩负着重返影像领域顶尖的使命。那么这次P70会带来哪些令人惊艳的创新呢?
根据目前爆料的消息来看,华为P70系列将推出三个版本,其中P70和P70 Pro采用了三角形的摄像头模组设计,而P70 Art则采用了与上一代P60 Art相似的不规则形状设计。这样的外观是否好看见仁见智,但辨识度绝对拉满。