Advertisement
prabapro

Converting date format: mmm dd, yyyy to mm/dd/yyyy

May 17th, 2022
652
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function() {
  2.   var date = {{dlv - date}}.split(/\s/);
  3.   var mo = date[0];
  4.   var dt = date[1].replace(',', '');
  5.   var yr = date[2];
  6.   var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', ];
  7.   for (var j = 0; j < months.length; j++) {
  8.     if (mo == months[j]) {
  9.       mo = months.indexOf(months[j]) + 1;
  10.     }
  11.   }
  12.   if (mo < 10) {
  13.     mo = '0' + mo;
  14.   }
  15.   var formattedDate = mo + '/' + dt + '/' + yr; //mm/dd/yyyy
  16.   return formattedDate;
  17. }
Advertisement
RAW Paste Data Copied
Advertisement