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

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -