{"name":"moonPhase","title":"moonPhase","type":"command","url":"https://community.bistudio.com/wiki/moonPhase","revid":377266,"updated":"2026-01-02T06:34:11Z","groups":["Environment"],"status":"ok","games":{"arma3":"1.58"},"since":"arma3 1.58","arma3_since":"1.58","description":"Returns the phase of the in-game Moon on the given date.\nAccording to this command, the fullest Moon in Arma 3 at midnight is on `setDate [4804, 7, 13, 0, 0];`.\nUse the Moon Phase Utility to find out a scenario date with desired moon.","syntaxes":[{"syntax":"moonPhase date","params":[{"name":"date","type":"Date","type_expr":"Date"}],"returns":{"type":"Number in 0..1 range","type_expr":"Number","description":"0 = new Moon, 1 = full Moon"},"form":"unary","right":{"text":"date"}}],"examples":[{"code":["private _currentMoonPhase = moonPhase date;"]},{"text":"```sqf\n// Returns array of dates for given year when moon is at its fullest\nfnc_fullMoonDates =\n{\n    private _year = param [0, 2035];\n    private [\"_date\", \"_phase\", \"_fullMoonDate\"];\n    private _fullMoonPhase = 1;\n    private _waxing = false;\n    private _fullMoonDates = [];\n    for \"_i\" from dateToNumber [_year, 1, 1, 0, 0] to dateToNumber [_year, 12, 31, 23, 59] step 1 / 365 do\n    {\n        _date = numberToDate [_year, _i];\n        _phase = moonPhase _date;\n\n        call\n        {\n            if (_phase > _fullMoonPhase) exitWith\n            {\n                _waxing = true;\n                _fullMoonDate = _date;\n            };\n\n            if (_waxing) exitWith\n            {\n                _waxing = false;\n                _fullMoonDates pushBack _fullMoonDate;\n            };\n        };\n\n        _fullMoonPhase = _phase;\n    };\n\n    _fullMoonDates;\n};\n\n//set random full moon date in year 1970\nsetDate selectRandom (1970 call fnc_fullMoonDates);\n```","code":["// Returns array of dates for given year when moon is at its fullest\nfnc_fullMoonDates = \n{\n\tprivate _year = param [0, 2035];\n\tprivate [\"_date\", \"_phase\", \"_fullMoonDate\"];\n\tprivate _fullMoonPhase = 1;\n\tprivate _waxing = false;\n\tprivate _fullMoonDates = [];\n\tfor \"_i\" from dateToNumber [_year, 1, 1, 0, 0] to dateToNumber [_year, 12, 31, 23, 59] step 1 / 365 do\n\t{\n\t\t_date = numberToDate [_year, _i];\n\t\t_phase = moonPhase _date;\n\n\t\tcall\n\t\t{\n\t\t\tif (_phase > _fullMoonPhase) exitWith\n\t\t\t{\n\t\t\t\t_waxing = true;\n\t\t\t\t_fullMoonDate = _date;\n\t\t\t};\n\n\t\t\tif (_waxing) exitWith \n\t\t\t{\n\t\t\t\t_waxing = false;\n\t\t\t\t_fullMoonDates pushBack _fullMoonDate;\n\t\t\t};\n\t\t};\n\n\t\t_fullMoonPhase = _phase;\n\t};\n\n\t_fullMoonDates;\n};\n\n//set random full moon date in year 1970\nsetDate selectRandom (1970 call fnc_fullMoonDates);"]}],"see_also":["moonIntensity","sunOrMoon"]}