Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display date-time in HH:MM AM format in Ionic

I have a date string "2017-01-19 10:34:36", it's coming from API.

I want to display it in HH:MM AM format in Ionic

like image 311
om_jaipur Avatar asked Jan 19 '17 07:01

om_jaipur


People also ask

How do you display dates in ionic?

Usage with Datetime Button​ If you need to present a datetime in an overlay such as a modal or a popover, we recommend using ion-datetime-button. ion-datetime-button should be used when space is constrained. This component displays buttons which show the current date and time values.

How do you format a date?

The international standard recommends writing the date as year, then month, then the day: YYYY-MM-DD.


1 Answers

To display datetime, you can just do it in angular2 way, using a pipe. Angular2 provides a DatePipe. You can use it like this:

{{info.createdDate | date: "yyyy/MM/dd HH:mm:ss"}}

[update]

If you want to display as format 'HH:MM AM', just use:

{{info.createdDate | date: "shortTime"}}

will be fine.

like image 162
Mavlarn Avatar answered Oct 01 '22 01:10

Mavlarn