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.
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
Post a Comment