After receiving the string from the REST API as "20160220", I am aiming to format it as "20/02/2016".
Utilizing AngularJS for this task, I understand that I will need to implement a filter. I have already attempted the code snippet below:
app.filter('myDateFilter', function() {
return function(input) {
var st = input;
var pattern = /(\d{4})(\d{2})(\d{2})/;
var date = new Date(st.replace(pattern, '$1-$2-$3'));
return date;
}
});
Furthermore, in my HTML code, I have included the following:
<td>
{{t["due-date"] | myDateFilter}}
</td>
However, the output I receive is "2016-02-20T00:00:00.000Z". Could this be an issue with the regular expression? I would greatly appreciate it if you could provide me with the correct code snippet that could be used instead to generate "20/02/2016".