I'm trying to get the date in the above format, and I'm doing it in Javascript. Here is what I'm trying to do, but it doesn't seem to want to work. It's giving me an object doesn't support this property or method
error.
var today = new Date();
var currentDate = ('0' + today.getDate()).slice(-2) + '-' + ('0' + (today.getMonth()+1)).slice(-2) + '-' + today.getFullYear().slice(-2);
alert(currentDate);
The idea, if it isn't obvious, is to add a 0 to the front of each piece and then slice off the last two digits. That way, if it's a 9, it'll add a 0 to the front, and keep the 09. If it's a 10, it'll add a 0 (so we have 010) but only keep the last two digits: 10
.
However, I've got that awesome error, so I can't figure out what I'm doing wrong.