Easiest code to convert date format from Books to CRM

Easiest code to convert date format from Books to CRM

There's got to be a better way....?

Books - 06 Sep 2022
CRM - 2022-08-27

  1. day = estimated_ship_date.left(2);
  2. year = estimated_ship_date.right(4);
  3. month = estimated_ship_date.subText(3,6).lower();
  4. info month;
  5. // 06 Sep 2022
  6. // 2022-08-27
  7. if(month == "sep")
  8. {
  9. month = "07";
  10. }
  11. else if(month == "feb")
  12. {
  13. month = "02";
  14. }
  15. estimated_ship_date = year + "-" + month + "-" + day;