Reputation: 191
I've followed the tutorial on this link: http://trulycode.com/bytes/easy-countdown-to-date-with-javascript-jquery/
How I can change date format
$("#countdown").countdown({
date: "8 September 2020 09:00:00",
format: "on"
});
from:
date: "8 September 2020 09:00:00",
to:
date: "2020-9-8 09:00:00",
Hope anyone can help me.
Upvotes: 1
Views: 213
Reputation: 11509
You can parse it and then display however you want:
var date = new Date(Date.parse("8 September 2020 09:00:00"))
var newFormat = '' + date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.toTimeString().slice(0,8)
// -> 2020-9-8 09:00:00
Note that getMonth()
indexes from 0, so September will be 8, which is why you have to add 1 if you want it to be 9.
Upvotes: 1