ASP 에서 yyyy-MM-dd hh:mm:ss.sss 형식으로 

날짜시간을 뽑는 함수이다.

 

기존 출처 블로그에서 밀리세컨드까지 추가시켰음.

 

2022-07-07 10:14:31.620 와 같이 출력됨.

 

' 현재시간 Format별로 가져오기
Function getDateTimeFormat(obj_date, dateFormat)
	Dim reValue, msType

	msType = False

	if false = IsDate(obj_date) then
		obj_date = now
	end if

	if dateFormat = "" then
		dateFormat = "yyyy-mm-dd h:n:s"
		msType = True
	end if

	' 밀리세컨드를 구함
	ms = Right("000" & (Timer * 1000) Mod 1000, 3)

	reValue = Replace(dateFormat, "yyyy", Year(obj_date))
	reValue = Replace(reValue, "mm", right("0" & Month(obj_date) , 2))
	reValue = Replace(reValue, "dd", right("0" & Day(obj_date) , 2))
	reValue = Replace(reValue, "h", right("0" & Hour(obj_date) , 2))
	reValue = Replace(reValue, "n", right("0" & Minute(obj_date) , 2))
	reValue = Replace(reValue, "s", right("0" & Second(obj_date) , 2))

	If msType = True Then 
		reValue = reValue & "."& ms
	End If

	getDateTimeFormat = reValue
End Function

 

 

# 원본 출처

http://www.songtory.com/post/001001/1/127

 

[ASP] 날짜형식 변환 (dateFormat) : [songtory.com]

하여간 ASP는 여러가지로 귀찮게 함..;; Function get_DateTimeFormat(obj_date, dateFormat) Dim reValue if false = IsDate(obj_date) then obj_date = now end if if dateFormat = "" then dateFormat = "yyyy-mm-dd-h:n:s" end if reValue = Replace(dateFor

www.songtory.com

 

  • 네이버 블러그 공유하기
  • 네이버 밴드에 공유하기
  • 페이스북 공유하기
  • 카카오스토리 공유하기