date_get_month 함수 설명
date_get_month
함수는 주어진 날짜 및 시간 값에서 월을 반환하는 기능을 제공합니다.
문법
date_get_month(date);
매개변수
매개변수 | 유형 | 설명 |
---|---|---|
date | datetime | 확인할 날짜 및 시간 값 |
반환값
- 이 함수는 주어진 날짜의 월을 정수로 반환합니다.
예제
mymonth = date_get_month(date_current_datetime());
위 코드는 mymonth
변수를 현재 월로 설정합니다.
활용 예제
예제 1: 현재 월 출력하기
var current_month = date_get_month(date_current_datetime());
show_message("현재 월은: " + string(current_month));
예제 2: 특정 날짜의 월 가져오기
var specific_date = date_create(2023, 10, 15);
var month_of_specific_date = date_get_month(specific_date);
show_message("특정 날짜의 월은: " + string(month_of_specific_date));
예제 3: 월에 따라 다른 메시지 출력하기
var current_month = date_get_month(date_current_datetime());
if (current_month == 12) {
show_message("현재는 12월입니다!");
} else {
show_message("현재는 12월이 아닙니다.");
}
예제 4: 월을 기반으로 계절 결정하기
var current_month = date_get_month(date_current_datetime());
var season;
if (current_month >= 3 && current_month <= 5) {
season = "봄";
} else if (current_month >= 6 && current_month <= 8) {
season = "여름";
} else if (current_month >= 9 && current_month <= 11) {
season = "가을";
} else {
season = "겨울";
}
show_message("현재 계절은: " + season);
예제 5: 월별 이벤트 관리
var current_month = date_get_month(date_current_datetime());
switch (current_month) {
case 1:
show_message("새해 복 많이 받으세요!");
break;
case 2:
show_message("발렌타인 데이!");
break;
case 12:
show_message("크리스마스가 다가옵니다!");
break;
default:
show_message("특별한 이벤트가 없습니다.");
}
이와 같이 date_get_month
함수를 활용하여 다양한 날짜 및 시간 관련 기능을 구현할 수 있습니다.