Reputation: 8151
I have the following line;
body += "Date: " + myDateVar | date:'dd-MM-yyyy HH:mm' + ".";
My question is, how do i correctly format the line above, so the format actually works? I get an error, but this works fine, but just no formatting:
body += "Date: " + myDateVar + ".";
Upvotes: 2
Views: 46
Reputation: 619
Supposing your code is in controller.
You need to inject in the controller the $filter service, then use it like this:
yourFilteredDate= $filter('date')(myDateVar, "dd-MM-yyyy HH:mm");
Because you can use the pipe | only in views.
Upvotes: 2