forceTwoDigits = (val) ->
if val < 10
return "0#{val}"
return val
formatDate = (date) ->
year = date.getFullYear()
month = forceTwoDigits(date.getMonth()+1)
day = forceTwoDigits(date.getDate())
hour = forceTwoDigits(date.getHours())
minute = forceTwoDigits(date.getMinutes())
second = forceTwoDigits(date.getSeconds())
return "#{year}#{month}#{day}#{hour}#{minute}#{second}"
console.log(formatDate(new Date()))
Is there a better way to do this?