Skip to content

Instantly share code, notes, and snippets.

@brandonhuff
Created January 3, 2016 23:08
Show Gist options
  • Save brandonhuff/fdc1aa9e0ca6297555a0 to your computer and use it in GitHub Desktop.
Save brandonhuff/fdc1aa9e0ca6297555a0 to your computer and use it in GitHub Desktop.
Angular 2 Beta.0 pipe for converting ISO 8601 string dates to javascript Date type.
// https://en.wikipedia.org/wiki/ISO_8601
// Example
// Usage: {{ dateValue | unicodeToDate | date:'MM/dd/yyyy' }}
// Data: 2014-01-05T18:14:18.32
// Result: 01/05/2014
import {Pipe} from 'angular2/core';
@Pipe({name: 'unicodeToDate'})
export class UnicodeToDatePipe {
transform(value:string, args:string[]) : any {
return new Date(value);
}
}
@johnwheeler
Copy link

thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment