FormatDateTime 함수 - Classic ASP 언어 (11)

FormatDateTime 함수 – Classic ASP 언어 (11)

FormatDateTime 함수는 Classic ASP에서 날짜 또는 시간 형식의 표현식을 반환하는 함수입니다. FormatDateTime 함수는 Date 매개변수와 Format Number 매개변수를 사용하여 사용자가 원하는 날짜 및 시간 형식을 지정할 수 있습니다. Format Number 매개변수를 생략하면 vbGeneralDate 형식이 사용됩니다. Classic ASP에서 FormatDateTime 함수를 활용하여 날짜와 시간을 다양한 형식으로 표현할 수 있습니다.


1. 구문

FormatDateTime(Date, [Format Number])

Format Number 생략 시 vbGeneralDate 가 사용됩니다.

[Format Number]

상수설명
vbGeneralDate0날짜 및/또는 시간을 표시합니다. 날짜 부분이 있으면 짧은 날짜로 표시합니다. 시간 부분이 있으면 긴 시간으로 표시합니다. 있는 경우 두 부분이 모두 표시됩니다.
vbLongDate1컴퓨터의 국가별 설정에 지정된 긴 날짜 형식을 사용하여 날짜를 표시합니다.
vbShortDate2컴퓨터의 국가별 설정에 지정된 간단한 날짜 형식을 사용하여 날짜를 표시합니다.
vbLongTime3컴퓨터의 국가별 설정에 지정된 시간 형식을 사용하여 시간을 표시합니다.
vbShortTime424시간 형식(hh:mm)을 사용하여 시간을 표시합니다.


2. 사용 예제

<% Option Explicit %>
     
<%
   Response.write "[FormatDateTime 함수 예제]" & "</br></br>"

   Response.write "FormatDateTime(Date)    : " & FormatDateTime(Date) & "</br>"
   Response.write "FormatDateTime(Date, 0) : " & FormatDateTime(Date, 0) & "</br>"
   Response.write "FormatDateTime(Date, 1) : " & FormatDateTime(Date, 1) & "</br>"
   Response.write "FormatDateTime(Date, 2) : " & FormatDateTime(Date, 2) & "</br>"
   Response.write "FormatDateTime(Date, 3) : " & FormatDateTime(Date, 3) & "</br>"
   Response.write "FormatDateTime(Date, 4) : " & FormatDateTime(Date, 4) & "</br>"
%>
실행 화면입니다.

관련 이전 게시글


이 글이 도움이 되셨다면 공유를 부탁드립니다. 다음 글에서 뵙겠습니다!

위로 스크롤