Given a bash variable with the value 2019-08-15, is there some utility that can convert that date to the format August 15, 2019?


On Linux, or any system that uses GNU date:

$ thedate=2019-08-15
$ date -d "$thedate" +'%B %e, %Y'
August 15, 2019

On macOS, OpenBSD and FreeBSD, where GNU date is not available by default:

$ thedate=2019-08-15
$ date -j -f '%Y-%m-%d' "$thedate" +'%B %e, %Y'
August 15, 2019

The -j option disables setting the system clock, and the format string used with -f describes the input date format (should be a strptime(3) format string describing the format used by your variable's value). Then follows the value of your variable and the format that you want your output to be in (should be a strftime(3) format string).

NetBSD users may use something similar to the above but without the -f input_fmt option, as their date implementation uses parsedate(3). Note also the -d option to specify the input date string:

$ thedate=2019-08-15
$ date -j -d "$thedate" +'%B %e, %Y'
August 15, 2019

See also the manual for date on your system.


Assuming that you have access to GNU date, something along

$ date --date="2019-08-15" "+%B %d, %Y"
August 15, 2019

Check the manpage of date (man date).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.