data = { name: 'Jaun', date: '2019-01-01 13:29:00', load: true }
what I want to do here is to format the date when it console the data it should be like this.
data = { name: 'Jaun', date: '01-01-2019 01:29 PM', load: true }
try this.
var data = { name: 'Jaun', date: '2019-01-01 13:29:00', load: true }
function convertDate(){
console.log(moment(data.date).format('DD-MM-YYYY hh:mm'));
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
<button onclick="convertDate()">Convert Date</button>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With