VBScript格式化时间

Function Format_DateWithoutTime_by_FormatString(dateValue,fString)
	intYear = Year(dateValue)
	intMonth = Month(dateValue)
	intDay = Day(dateValue)
	
	intMonth2 = intMonth
	intDay2 = intDay
	If intDay2 <10 Then
        intDay2 = 0&CStr(intDay2)
    End If
    If intMonth2 <10 Then
        intMonth2 = 0&CStr(intMonth2)
    End If
	select case fString
		case "yyyy-mm-dd" 
			Format_DateWithoutTime_by_FormatString = intYear&"-"&intMonth2&"-"&intDay2
		case "yyyy-m-d" 
			Format_DateWithoutTime_by_FormatString = intYear&"-"&intMonth&"-"&intDay
		case "mm/dd/yyyy" 
			Format_DateWithoutTime_by_FormatString = intMonth2&"/"&intDay2&"/"&intYear
		case "m/d/yyyy" 
			Format_DateWithoutTime_by_FormatString = intMonth&"/"&intDay&"/"&intYear
		case else
			Format_DateWithoutTime_by_FormatString = -1
	end select
End Function
 

你可能感兴趣的:(VBScript)