How would you parse a date in bash, with separate fields (years, months, days, hours, minutes, seconds) into different variables?
The date format is: YYYY-MM-D
YYYY-MM-D
The array method is perhaps better, but this is what you were specifically asking for:
IFS=" :-" read year month day hour minute second < <(echo "YYYY-MM-DD hh:mm:ss")