Version: v0.7.1 - Beta.  We welcome contributors & feedback.

Date.add

$date.add($durationString) -> Date

Description

Add a time duration to a Date object, and return a new Date object.

The duration can be a number of seconds, or a string (e.g. '3 hours', '2 weeks', etc.).

Pass in a negative duration to create a past date.

This method does NOT modify the original date.

$now = Date.now()

$oneHourLater = $now.add(3600)
$oneHourLater = $now.add('1 hour')

$pastDate = $now.add('-10 weeks')

$futureDate = $now.add('1 month + 3 days')

See Also