I am running a query on a Parse.com object and returning the updatedAt
and wish to display this as a nicely formatted date for my users on my Ionic App.
It currently displays like this:
2015-03-27T21:38:22.606Z
I would like this to display as:
27-03-2015 at 21:38
an example of the object that I am using to display this data is below:
var programmeData = {
programmeTitle : object.get('prescribedProgrammeTitle'),
id : object.id,
exerciseData : object.get('exerciseData'),
prescribedDate :object.updatedAt,
};
I can run formatting in my controller / service or view - advice on how to do this correctly would be great.
You can use the AngularJS date filter.
To format it directly in html you would need to put programmeData on the $scope:
{{ programmeData | date: 'dd-MM-yyyy at HH:mm' }}
Or in your controller you could inject $filter to format it:
$filter('date')(programmeData, 'dd-MM-yyyy at HH:mm');
There are many ways to parse the date using this library.