Let’s see the function:
var split_space = date_input.split(' ');
var date_part = space;
var date_explode = date_part.split('-');
var new_date = date_explode+'-'+date_explode+'-'+date_explode+' '+space;
Here I have extracted the date and time with split function then again split date part with split function and then combine the exploded part and create your own format of the date.
Also Read: To convert DATE in other language in PHP
That’s it. I hope that you find this tutorial useful to someone.
Don’t hesitate to use this code in your projects and post your comments if you need help. As always, thanks for reading. Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.