How to manipulate string from json


#1

How i can manipulate a string from json response?

I have this string 20161120 and i would transform in 20/11/2016 or rather dd/mm/yyyy

I read that are the pipes but i don’t see any example for work with these.

Someone help me?

Thank You!


#2

Yeah you should search in Angular2 docs for “Pipe” :wink:

or you simply create a custom transformation function with a regexp to get year, month, day separated. After that you can create a real JavaScript Date object and use the build in date pipe of angular 2
https://angular.io/docs/ts/latest/api/common/index/DatePipe-pipe.html


#3

Thank You for solution.

I modify the data with pipes and now it works!