Script calculates the date and time when an event ends, since the start date+time and it duration.
Find a file
2026-02-26 21:27:33 -03:00
date-hour-duration-bash.sh MacOS date compatibility + License 2026-02-22 02:05:22 -03:00
date-hour-duration-zenity.sh Bash testing - Zenity completed 2015-11-03 21:00:58 -03:00
LICENSE add LICENSE doc 2026-02-26 21:27:33 -03:00
README.md MacOS date compatibility + License 2026-02-22 02:05:22 -03:00

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:
    • 30m
    • 2h
    • 1d4h30m
    • 2w3d
  • 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

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.

http://www.wtfpl.net/

WTFPL badge