I am using a named template to generate the html for an object hanging off my view model. This works fine.
One of the properties of my object is a date in UTC. I would like to convert that date to the timezone of the users browser before the html is generated.
I can listen to the afterRender event and set the html element value then, but I’m curious if a cleaner way exists?
in my template I was wondering how to do the following…?
<div data-bind="text: 'CreatedOn: ' + localizeDate(CreatedOn);"</div>
....
function localizeDate(dateTolocalize) {.... };
I have searched the documentation but couldn’t find it.
Thanks,
Wow i’m an idiot! It appears you can easily call functions within a template, just don’t include the semi-colon at the end of your statement.
That works well 🙂