stormec56 stormec56 - 9 months ago 50
AngularJS Question

How to Exclude Hours, Minutes and Seconds in AngularJS Date?

I'm receiving data from

file via
request. In my JSON file this is the format I receive:

"date": "2016-10-24 15:14:53"

I want to format it to be like this:
October 10 2016

My code:

<body data-ng-app="myApp">

<div data-ng-controller="alfaCtrl1" class="blogwrapper" id="blogFirst">
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http) {
$http.get('jsonfile.json').success(function(data) {
$ = data.posts[0].date;

This question is different from the one proposed as "duplicate", since it expands the process to Angular way of formatting date.

Answer Source
var formateDate = new Date(data.posts[0].date)
$ = $filter('date')(formateDate, 'longDate');