If you do want to do it in just native JavaScript, then here is a straight forward (not overly clever) approach. A couple of functions that then take a date and format as you wanted.
var d = new Date()alert(fmtdate(d))function fmtdate(d) { return d.getFullYear()+zpad2(d.getMonth()+1)+zpad2(d.getDate())+zpad2(d.getHours())+zpad2(d.getMinutes())+zpad2(d.getSeconds())}function zpad2(n) { if (n<10) { n = ("0"+n); } return n;}
Open in new window
~bp