For Couchbase SDKs which accept simple integer expiry values (as opposed to a proper date or time object) allow expiration to be specified in two flavors.
As an offset from the current time.
As an absolute Unix time stamp
If the absolute value of the expiry is less than 30 days ( 60 * 60 * 24 * 30 seconds), it is considered an offset . If the value is greater, it is considered an absolute time stamp .
It might be preferable for applications to normalize the expiration value, such as by always converting it to an absolute time stamp. The conversion is performed to avoid issues when the intended offset is larger than 30 days, in which case it is taken to mean a Unix time stamp and, as a result, the document will expire automatically as soon as it is stored.
Just to add to @vsr1’s answer: Node.js deals with dates almost entirely in terms of ‘milliseconds since epoch’, where as standard unix timestamps are ‘seconds since epoch’. So in your case, again you need to perform that conversion:
// Using Dates's directly:
expiry: (new Date()).getTime() / 1000
// Since I saw you are using moment:
expiry: moment().add(40, "days").unix()