Skip to content Skip to sidebar Skip to footer

How To Cut Out A Piece Of A String With Javascript Jquery?

I am having a string like below and i want to cut out the T with the time from it like below: var string = '2021-05-10T08:00,2021-05-11T08:00,2021-05-12T08:00'; My new string shou

Solution 1:

Break it into an array and process each chunk. map is a good function for this

 var string = '2021-05-10T08:00,2021-05-11T08:00,2021-05-12T08:00';
    var newstring = string.split(",").map(el => el.split('T')[0]).join(",");
    console.log(newstring);

Post a Comment for "How To Cut Out A Piece Of A String With Javascript Jquery?"