date format function to display date as “Jan 13 2014”

前端 未结 3 1050
渐次进展
渐次进展 2020-12-07 05:33

Is there any function to display date in the format mmm-dd-yyyy in VBScript? eg. today\'s date as Jan 22 2014?

I tried using function

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-07 06:10

    Below function will help which is returning in "dd-mmm-yyyy hh:mm:ss" format. You can customize the format according to your need.

    Function timeStampForLogging(t)
        Dim Months
    
        Months = Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", _ 
                       "Jul", "Aug", "Sep", "Oct", "Nov", "Dec") 
    
    
        timeStampForLogging =  Right("0" & Day(t),2)& "-" & _
        Months(Month(t)-1)  & "-" & _
        Year(t) & " " & _  
        Right("0" & Hour(t),2) & ":" & _
        Right("0" & Minute(t),2) & ":" & _
        Right("0" & Second(t),2) 
    End Function
    

提交回复
热议问题