Date | playing with the date
Creating datestamps + 15min
Bash
#!/bin/bash
## User-specified dates.
# See [GNU Coreutils: Date] for more info
# [GNU Coreutils: Date]: https://www.gnu.org/software/coreutils/manual/html_node/Combined-date-and-time-of-day-items.html#Combined-date-and-time-of-day-items
begin_date="2024-01-01T00:00"
end_date="2024-02-01T00:00"
# Run through `date` to ensure iso-8601 consistency
startdate=$(date --iso-8601='minutes' --date="${begin_date}")
enddate=$(date --iso-8601='minutes' --date="${end_date}")
# Do loop
d="$startdate"
while [ "$d" != "$enddate" ]; do
echo $d | cut -b1-16 | sed 's/T/-/g'
d=$(date --iso-8601='minutes' --date="$d + 15 minutes")
done