ASP date Format function

Source: Internet
Author: User

============================================
Format time (display)  
Parameters: n_flag 
1: "Yyyy-mm-dd hh:mm:ss "&NBSP
2:" Yyyy-mm-dd " 
3:" Hh:mm:ss " 
4:" YYYY year mm month DD Day " 
5:" YYYYMMDD " 
6:" 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) = 1 Then m = "0" & M
 d = CST R (Day (s_time))
 if len (d) = 1 Then D = "0" & D
 h = CStr (Hour (s_time))
 if len (h) = 1 Th En h = "0" & H
 mi = CStr (Minute (s_time))
 if len (mi) = 1 Then mi = "0" & mi
 s = CS TR (second (s_time))
 if len (s) = 1 Then s = "0" & S
 select case N_flag
 case 1 
  YYYY-MM-DD HH:MM:SS
 formattime = y & "-& M &"-"& D &" "& H &": "& Mi &": "& S
 case 2 
 yyyy-mm-dd
 formattime = y & "-& M &"-"& D
 case 3 
 hh:m M:SS
 formattime = h & ": & Mi &": "& S
 case 4 
  yyyy year mm month DD Day
&N Bsp Formattime = y & "Year" & M & "Month" & D & "Day"
 case 5 
  YYYYMMDD
 format Time = y & M & D
 case 6 
 yyyymmddhhmmss
 formattime= y & M & D & H & Mi & S
 end Select
End Function
%>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.