Created
January 17, 2012 22:33
-
-
Save tamitutor/1629439 to your computer and use it in GitHub Desktop.
Handlebars Date Helper - ASP.NET Date to JavaScript Date
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
var offset = new Date().getTimezoneOffset() * 60 * 1000; | |
function parseAspNetUTCDateToJSDate(jsonDate) { | |
var parsedDate = new Date(parseInt(jsonDate.substr(6)) + offset); | |
return parsedDate; | |
} | |
Handlebars.registerHelper('date', function (date, block) { | |
return parseAspNetUTCDateToJSDate(date).toDateString(); //Return a shortened version of the date | |
}); |
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
<table class="interventions-view fill"> | |
<thead> | |
<tr> | |
<td>Name</td> | |
<td>Type</td> | |
<td>Begin Date</td> | |
<td>Status</td> | |
<td>Result</td> | |
</tr> | |
</thead> | |
<tbody> | |
{{#each Records}} | |
<tr> | |
<td> | |
{{Name}} | |
</td> | |
<td> | |
{{Type}} | |
</td> | |
<td> | |
{{date StartDate}} | |
</td> | |
<td> | |
{{Name}} | |
</td> | |
<td> | |
<img src="/static/img/{{ResultImage}}" title="{{ResultName}}" alt="{{ResultName}}"/> | |
</td> | |
</tr> | |
{{/each}} | |
</tbody> | |
</table> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Of course this is assuming your using UTCDate format on the ASP.Net side.