CoffeeScript Pretty Date formatting
To format a javascript date as a string in the form dd/mm/yy using coffeescript:
zero_pad = (x) ->
if x < 10 then '0'+x else ''+x
Date::pretty_string = ->
d = zero_pad(this.getDate())
m = zero_pad(this.getMonth() + 1)
y = this.getFullYear()
y + m + d
Written by Sam Davies
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Coffeescript
Authors
iam4x
94.17K
ericdfields
63.02K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#