Script calculates the date and time when an event ends, since the start date+time and it duration.
- Shell 100%
| date-hour-duration-bash.sh | ||
| date-hour-duration-zenity.sh | ||
| LICENSE | ||
| README.md | ||
Date Hour Duration
date-hour-duration is a small portable Bash script that calculates the end date and time of an event given:
- A start date
- A start time
- A duration (minutes, hours, days, or combined values)
It works on Linux (GNU date) and macOS (BSD date).
Features
- Cross-platform (Linux + macOS)
- Supports combined durations:
30m2h1d4h30m2w3d
- Validates input parameters
- Outputs:
- Start time
- Duration (human readable + seconds)
- End time
- Epoch timestamps
Usage
./date-hour-duration.sh YYYY-MM-DD HH:MM DURATION
Examples
./date-hour-duration.sh 2026-02-22 09:00 1h30m
./date-hour-duration.sh 2026-02-22 09:00 2d4h
./date-hour-duration.sh 2026-02-22 09:00 45m
Output example
Start : 2026-02-22 09:00:00 (1771741200)
Duration: 1d2h30m (1d 2h 30m = 95400s)
End : 2026-02-23 11:30:00 (1771836600)
Duration format
| Unit | Meaning | Example |
|---|---|---|
m |
minutes | 30m |
h |
hours | 2h |
d |
days | 1d |
w |
weeks | 2w |
You can combine them 1w2d3h30m
History
2015-11-02
- Bash script with parameter validation
- Support for minutes
- Zenity version with parameter checks and GNU date detection
2015-11-01
- First release as a simple Pastebin snippet
- http://pastebin.com/hhwr4j09
- Zenity-based GUI version
2026-02-22
- Migrate to self-hosted Forgejo git
- Improve compatibility with MacOS date
- Improve output
- Unmaintain Zentry script
License
Licensed under the WTFPL v2.
