Skip to content

Instantly share code, notes, and snippets.

@mikaelvesavuori
Created December 27, 2022 14:55
Show Gist options
  • Save mikaelvesavuori/f35b7cbcf8e66628bfc5aca21680250d to your computer and use it in GitHub Desktop.
Save mikaelvesavuori/f35b7cbcf8e66628bfc5aca21680250d to your computer and use it in GitHub Desktop.
Create and return 10-digit Unix-formatted expiration time for a DynamoDB item.
/**
* @description Create and return 10-digit Unix-formatted expiration time for a DynamoDB item.
*/
export function getExpiryTime(expirationInMinutes = 10): string {
const date = new Date();
return date
.setMinutes(date.getMinutes() + expirationInMinutes)
.toString()
.substring(0, 10);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment