熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

asp 日期格式化函數

2022-06-13   來源: .NET編程 

  ============================================
格式化時間(顯示) 
參數n_Flag 
:"yyyymmdd hh:mm:ss" 
:"yyyymmdd" 
:"hh:mm:ss" 
:"yyyy年mm月dd日" 
:"yyyymmdd" 
:"yyyymmddhhmmss" 
============================================
Function FormatTime(s_Time n_Flag)
 Dim y m d h mi s
 FormatTime = ""
 If IsDate(s_Time) = False Then Exit Function
 y = cstr(year(s_Time))
 m = cstr(month(s_Time))
 If len(m) = Then m = "" & m
 d = cstr(day(s_Time))
 If len(d) = Then d = "" & d
 h = cstr(hour(s_Time))
 If len(h) = Then h = "" & h
 mi = cstr(minute(s_Time))
 If len(mi) = Then mi = "" & mi
 s = cstr(second(s_Time))
 If len(s) = Then s = "" & s
 Select Case n_Flag
 Case  
  yyyymmdd hh:mm:ss
 FormatTime = y & "" & m & "" & d & " " & h & ":" & mi & ":" & s
 Case  
 yyyymmdd
 FormatTime = y & "" & m & "" & d
 Case  
 hh:mm:ss
 FormatTime = h & ":" & mi & ":" & s
 Case  
  yyyy年mm月dd日
 FormatTime = y & "年" & m & "月" & d & "日"
 Case  
  yyyymmdd
 FormatTime = y & m & d
 case  
 yyyymmddhhmmss
 FormatTime= y & m & d & h & mi & s
 End Select
End Function
%>


From:http://tw.wingwit.com/Article/program/net/201311/12559.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.