Skip to main content

Duration

The duration represents a length of time in Wing.

You can use this to get durations representing the amount of milliseconds, seconds, minutes, hours, days, and years.

main.w
let msInHour = duration.fromHours(1).milliseconds;
let msInSeconds = duration.fromSeconds(30).milliseconds;
let secondsInDay = duration.fromDays(1).seconds;
let hoursInDay = duration.fromDays(1).hours;
let hoursInMonth = duration.fromMonths(1).hours;
let daysInYear = duration.fromYears(1).days;

let durations = {
msInHour,
msInSeconds,
secondsInDay,
hoursInDay,
hoursInMonth,
daysInYear
};

log(Json.stringify(durations));
Wing console output
# Run locally with wing console
{"msInHour":3600000,"msInSeconds":30000,"secondsInDay":86400,"hoursInDay":24,"hoursInMonth":730,"daysInYear":365}