This seems to be a simple question. I use pipes in my Ionic 2 application for date format. This is the webservice response received.
[ { "MessageID": 544882, "CategoryID": 1, "DateSent": "2015-05-18T02:30:56", "Title": "Jobseeker App", "MessageContent": "Hi Test guy just started to use the app..", "Sender": null, "Recipient": null, "DateReceived": null, "DateRead": "2015-05-18T02:30:56", "Note_Direction": "sent", "Viewed": 0, "AppointmentDateTime": null, "MessageAttachments": [ ] }, { "MessageID": 544886, "CategoryID": 1, "DateSent": "2015-05-18T02:42:45", "Title": "Jobseeker App", "MessageContent": "App", "Sender": null, "Recipient": null, "DateReceived": null, "DateRead": "2015-05-18T02:42:45", "Note_Direction": "sent", "Viewed": 0, "AppointmentDateTime": null, "MessageAttachments": [ ]} ]
This is a piece of code that I am using.
<div class="Date"> <label class="time">{{appointment.DateSent | date:"HH"}}:{{appointment.DateSent| date:"mm"}}</label> <label class="month">{{appointment.DateSent| date:"MMM"}}</label> <label class="day">{{appointment.DateSent| date:"dd"}}</label> <label class="year">{{appointment.DateSent| date:"yyyy"}}</label> </div>
Error:
Invalid argument '2015-05-18T02:30:56' for pipe 'DatePipe' in [{{appointment.DateSent | date:"HH"}}:{{appointment.DateSent| date:"mm"}} in AppointmentsPage@14 :37]
I need to get the date format as follows:
06:05 Dec 24 2015