-2

I have a string of new date value. How can I covert it into my expected output using vanilla JavaScript.

let str = "Sun May 01 2022 20:30:20 GMT+0600 (Bangladesh Standard Time)"

expected output: May 01, 2022

Irfan Emon
  • 1
  • 1
  • 2
  • Please edit your question and add in your JavaScript code that demonstrates your best attempt at resolving this yourself. There are a TON of similar questions on this site. What have you tried? – devlin carnate Jun 01 '22 at 15:14
  • 3
    Does this answer your question? [Parsing a string to a date in JavaScript](https://stackoverflow.com/questions/5619202/parsing-a-string-to-a-date-in-javascript) – devlin carnate Jun 01 '22 at 15:15

1 Answers1

1
var myDate="Sun May 01 2022 20:30:20 GMT+0600 (Bangladesh Standard Time)";
var dateArrays=myDate.split(" ");
var newDate=dateArrays[1]+" "+dateArrays[2]+", "+dateArrays[3]
console.log(newDate);
ZhangJian
  • 11
  • 3