Created
May 27, 2013 18:24
-
-
Save jwaltonmedia/5658411 to your computer and use it in GitHub Desktop.
Dustjs helper for formatting javascript date strings in templates (server-side).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dust.helpers.formatDate = function(chunk, context, bodies, params) { | |
var value = dust.helpers.tap(params.value, chunk, context), | |
timestamp, | |
month, | |
date, | |
year; | |
timestamp = new Date(value); | |
month = timestamp.getMonth() + 1; | |
date = timestamp.getDate(); | |
year = timestamp.getFullYear(); | |
return chunk.write(month + '.' + date + '.' + year); | |
}; | |
//then to use it: {@formatDate vale="{YOUR JS DATE VALUE}"/} | |
//how to make helpers? https://github.com/linkedin/dustjs/wiki/Dust-Tutorial#wiki-Writing_a_dust_helper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment