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()
-- Subtract 5 days
now:subtract(5, "days")
toast("Date after subtracting 5 days: " .. now:format("yyyy-MM-dd"))
-- Subtract 2 months
now = DateTime() -- Reset
now:subtract(2, "months")
toast("Date after subtracting 2 months: " .. now:format("yyyy-MM-dd"))