I have a function Im calling several times when I need to process a date:
dateFormat(myDate, format) {
let temp=this.datePipe.transform(myDate, format)
return(temp)
}
This just formats a date.
let niceDate=dateFormat(mydate, 'MM/dd/yyyy')
The problem is I need to call it from several components. I was looking at services it looks like its not what Im looking for (I may be wrong). Im wondering if this can be accomplished like in Node.js, but in Angular.
What is the right way to store several functions on one file, import that file and call the functions from other components?
Thanks.