date_datetime_string 함수 설명
date_datetime_string
함수는 주어진 날짜와 시간을 문자열로 변환하여 게임이 실행되고 있는 시스템 또는 장치의 형식에 맞게 포맷합니다. 이 함수는 날짜 및 시간 정보를 사용자에게 읽기 쉬운 형식으로 제공하는 데 유용합니다.
문법
date_datetime_string(date);
인수
인수 | 유형 | 설명 |
---|---|---|
date | 날짜 | 사용할 날짜 |
반환값
- 문자열 형태의 날짜 및 시간 정보
예제
str = date_datetime_string(date_current_datetime());
위 코드는 str
변수를 "2011년 9월 15일, 11:33.00"과 같은 형식으로 설정합니다. 이는 시스템의 날짜/시간 표시 설정과 현재 날짜 및 시간에 따라 달라질 수 있습니다.
활용 예제
예제 1: 현재 날짜 및 시간 표시
var currentDateTime = date_current_datetime();
var formattedDateTime = date_datetime_string(currentDateTime);
show_message(formattedDateTime);
이 코드는 현재 날짜와 시간을 포맷하여 메시지 박스로 표시합니다.
예제 2: 특정 날짜 포맷팅
var specificDate = date_create(2023, 10, 1, 12, 0, 0);
var formattedSpecificDate = date_datetime_string(specificDate);
show_message(formattedSpecificDate);
이 코드는 2023년 10월 1일 12시 0분 0초를 포맷하여 메시지 박스로 표시합니다.
예제 3: 날짜 비교
var date1 = date_create(2023, 1, 1);
var date2 = date_create(2023, 12, 31);
if (date1 < date2) {
show_message("date1이 date2보다 이전입니다.");
} else {
show_message("date1이 date2보다 이후입니다.");
}
이 코드는 두 날짜를 비교하여 메시지 박스로 결과를 표시합니다.
예제 4: 날짜 형식 변경
var currentDateTime = date_current_datetime();
var formattedDateTime = date_datetime_string(currentDateTime);
var customFormat = string_replace(formattedDateTime, ",", " at");
show_message(customFormat);
이 코드는 현재 날짜와 시간을 포맷한 후, 쉼표를 "at"으로 변경하여 표시합니다.