I have a string in the format "yyyymmdd". It is a string in bash and I want to get it converted into a date so that all other date functions can be used on it.
"20121212" string into "20121212" date with format "%Y%m%d".
Bash Date format YYYY-MM-DD To format date in YYYY-MM-DD format, use the command date +%F or printf "%(%F)T\n" $EPOCHSECONDS . The %F option is an alias for %Y-%m-%d . This format is the ISO 8601 format.
date +%S. Displays seconds [00-59] date +%N. Displays in Nanoseconds.
This worked for me :
date -d '20121212 7 days' date -d '12-DEC-2012 7 days' date -d '2012-12-12 7 days' date -d '2012-12-12 4:10:10PM 7 days' date -d '2012-12-12 16:10:55 7 days'
then you can format output adding parameter '+%Y%m%d'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With