DateTime():subtract()
DateTime 객체에서 지정한 시간을 뺍니다.
시그니처
subtract(amount: number, unit: string): DateTime
매개변수
| 매개변수 | 유형 | 설명 |
|---|---|---|
amount | number | 뺄 시간. |
unit | string | 뺄 시간의 단위. 지원되는 단위: years, year, months, month, weeks, week, days, day, hours, hour, minutes, minute, seconds, second, milliseconds, millisecond |
반환값
- 유형:
DateTime - 현재
DateTime인스턴스이며, 메서드 체이닝이 가능합니다.
예시
local now = DateTime()
-- 5일 빼기
now:subtract(5, "days")
toast("5일을 뺀 날짜: " .. now:format("yyyy-MM-dd"))
-- 2개월 빼기
now = DateTime() -- 초기화
now:subtract(2, "months")
toast("2개월을 뺀 날짜: " .. now:format("yyyy-MM-dd"))