SaveSnippets
Community
Pricing
Sign In
Get Started
Community
Public Snippets
2
Code shared by the SaveSnippets community — browse, copy, and get inspired.
All Languages
Bash
Go
HTML
Java
JavaScript
Kotlin
PHP
Python
Rust
SQL
TypeScript
#arithmetic
Clear
Tags
#php
#kotlin
#bash
#go
#sql
#rust
#typescript
#html
#java
#python
#files
#utils
#strings
#http
#concurrency
#async
#json
#arrays
#security
#types
#crypto
#database
#dates
#format
Bash
Days Between Two Dates
Convert both dates to epoch seconds, subtract, divide. Works for hours/minutes too with the obvious divisor.
#bash
#dates
#arithmetic
#epoch
Bash
Add / Subtract Time from Date
GNU date accepts natural-language deltas: "+1 day", "-3 weeks", "now + 2 hours". Combine with -d to compute against any reference date.
#bash
#dates
#arithmetic
#gnu-date