I want to create a pipe for angular2, and this is the code:
@Pipe({name: 'stringToDate'})
export class StringToDatePipe implements PipeTransform {
/**
* Constructor
*/
constructor() {
}
/**
* Transform a date that is passed as string into a date
* @param value The date passed as string
* @returns {Date} The Date object
*/
transform(value: string): Date {
console.log(value);
let d = new Date(value);
console.log(d);
return d;
}
}
I don't know why it is not creating the correct date. This is what console prints:
2016-01-01
Thu Dec 31 2015 21:00:00 GMT-0300
How can I fix it?