I try to extract and reorganize a date string? 2024-11-21 into 21-11-2024
Any help would be… Helpful 🙂
Thanks
I have a string in html
<h2 class="tg-item-meta-data tg-element-4">2024-11-21</h2>
I want to display date as 21-11-2024
I tried this to extract number
var number = parseInt(jQuery('.tg-item-meta-data tg-element-4').text()); alert(number);
But fails
How do I extract and reorganize a date string?
2
Answers
I add
jQuery( document.querySelector('.tg-item-meta-data.tg-element-4').replaceWith(result) );
to display the correct format in the html code but it's not realy working, tag and style are different. Is there another code to replace the previous date by 'result' in the same html line?You can try like this.
And this is code with
jQuery