본문으로 건너뛰기

DateTime():add()

DateTime 객체에 지정한 시간을 더합니다.

시그니처

add(amount: number, unit: string)

매개변수

매개변수유형설명
amountint더할 시간.
unitString더할 시간의 단위. 지원되는 단위: years, year, months, month, weeks, week, days, day, hours, hour, minutes, minute, seconds, second, milliseconds, millisecond

반환값

  • 유형: IDateTime
  • 현재 DateTime 인스턴스이며, 메서드 체이닝이 가능합니다.

예시

local now = DateTime()
-- 5일 더하기
now:add(5, "days")
toast("5일을 더한 날짜: " .. now:format("yyyy-MM-dd"))

-- 2개월 더하기
now = DateTime() -- 초기화
now:add(2, "months")
toast("2개월을 더한 날짜: " .. now:format("yyyy-MM-dd"))