Parsear date with bookshop momentjs

4

I want to pause the date like this (day: month: year "spaced" hour: minute: second)

I did the test with 2018-12-10T10:33:57-04:00 and it returns me 12/10/2018 10:12:00 that result is wrong, I need 10/12/2018 10:33:57

let fecha = '2018-12-10T10:33:57-04:00'
console.log(moment(fecha).format('MM/DD/YYYY  HH:MM:SS'));
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.15.1/moment.min.js"></script>

Another example with another date, the minute always comes out 12

let fecha2='2018-12-12T18:09:17-04:00';
console.log(moment(fecha2).format('MM/DD/YYYY  HH:MM:SS'));
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.15.1/moment.min.js"></script>
    
asked by x-rw 12.12.2018 в 22:55
source

1 answer

4

The minute and second format must be lowercase.

let fecha = '2018-12-10T10:33:57-04:00'
console.log(moment(fecha).format('MM/DD/YYYY  HH:mm:ss'));
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.15.1/moment.min.js"></script>
    
answered by 12.12.2018 / 23:17
source