jquery - Javascript: convert datetime to DD/MM/YYYY - Time? -


i have datetime looks this:

2017-04-17 18:26:03 

how can convert this format using javascript or jquery:

17/04/2017 18:26 

i found question thought might me answers converting timestamp mine not time stamp.

how convert datetime value dd/mm/yyyy in jquery?

you can use simple string , array manipulation.

const datetime = '2017-04-17 18:26:03';  const parts = datetime.split(/[- :]/);  const wanted = `${parts[2]}/${parts[1]}/${parts[0]} ${parts[3]}:${parts[4]}`;  console.log(wanted);

additional: if don't have environment supports template literals can write this.

const datetime = '2017-04-17 18:26:03';  const parts = datetime.split(/[- :]/);  const wanted = parts[2] + '/' + parts[1] + '/' + parts[0] + ' ' + parts[3] + ':' + parts[4];  console.log(wanted);


Comments

Popular posts from this blog

cookies - Yii2 Advanced - Share session between frontend and mainsite (duplicate of frontend for www) -

angular - password and confirm password field validation angular2 reactive forms -

php - Permission denied. Laravel linux server -