bjorkblom
bjorkblom

Reputation: 1959

Get JS date format string

For our Angular 4 application I'm using ngx-translate with messageformat.js for handling internationalization and localization. Is it possible to get the format string of shortdate of a date object ie. 'YYYY-MM-dd'?

ie: new Date().formatString('en-US') returns: 'YYYY-MM-dd'

Upvotes: 1

Views: 127

Answers (1)

DmitriyKhirniy
DmitriyKhirniy

Reputation: 245

const pipe: DatePipe = new DatePipe(locale) //en-Ukr
return pipe.transform(value, 'y-MM-DD') // value = new Date()
'2017-12-04'

Upvotes: -1

Related Questions