Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I 'm using bash I have a date string now, for example:
2015111301
(yyyymmddHH)
how to get the date string of next hour? that is:
2015111302
date +%Y%m%d%H
Try this:
in="2015111301" out="$(date -d "${in:0:8} ${in:8:2}:00:00 +1hour" '+%Y%m%d%H')" echo "$out"
Output:
See: 3.5.3 Shell Parameter Expansion
Add a comment
2015111306
This below script worked for me
#!/bin/bash tempval=$(echo 2015111301 | sed 's/\(.\{8\}\)/\1 /g') tempval=$(echo "$tempval 1 hour") date -d "$tempval" +%Y%m%d%H
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
date +%Y%m%d%Hcan get you such output