I am trying to dynamically convert one column in text file containing date in dd/mm/yyyy hh:mm:ss format to yy-mm-dd hh:mm:ss. Following command is working but giving output in yy-dd-mm and NOT yy-mm-dd as I need.
echo $(date -d "8/11/2018 06:20:57 AM" "+%y-%m-%d %H:%M:%S")
Moreover, this is not working for dates > 12 as it is treating first digit as month not date as below:
echo $(date -d "28/11/2018 06:20:57 AM" "+%y-%m-%d %H:%M:%S")
date: invalid date ‘28/11/2018 06:20:57 AM’
Is there any way to make it work?