AngularJs datepicker ui.bootstrap filter for selecting dates (2014-04-17 at 7:00am)

I am working on an Angular app in which I save dates from a datepicker provided by ui.bootstrap. I want to filter the dates and display them in a more readable format.

For example: 2014-04-17T07:00:00.000Z converted to 4/14/2014 or any other suitable option

Thank you!

Answer №1

Utilize Angular filter to format dates.

{{date  | date:'MM-dd-yyyy HH:MM:ss}}

For more information, refer to the following link - http://docs.angularjs.org/api/ng.filter:date

Demo (Live Example)

html

   <div ng-app='myApp' ng-controller="ArrayController">
            <li ng-repeat="arr in records ">
                {{arr.date| date:'MM/dd/yyyy'}}
            </li>
   </div>

script

var app = angular.module('myApp', []);
app.controller('ArrayController', function ($scope) {
    $scope.records = [{
        name: 'sohn',
        phone: '555-1212',
        age: 10,
        date: '2014-11-12T07:00:00.000Z'},
    {
        name: 'Mary',
        phone: '555-9876',
        age: 19,
        date: '2014-05-17T07:00:00.000Z'},
    {
        name: 'Mike',
        phone: '555-4321',
        age: 21,
        date: '2014-04-17T07:00:00.000Z'},
    {
        name: 'Adam',
        phone: '555-5678',
        age: 35,
        date: '2014-09-01T07:00:00.000Z'},
    {
        name: 'Julie',
        phone: '555-8765',
        age: 29,
        date: '2014-10-21T07:00:00.000Z'},
    {
        name: 'Julie',
        phone: '555-8765',
        age: 29,
        date: '2014-11-12T07:00:00.000Z'},
    {
        name: 'arlina',
        phone: '555-8765',
        age: 29,
        date: '2014-07-07T07:00:00.000Z'},
    {
        name: 'Mary',
        phone: '555-8765',
        age: 29,
        date: '2014-06-07T07:00:00.000Z'}
    ];
});

Output

11/12/2014
05/17/2014
04/17/2014
09/01/2014
10/21/2014
11/12/2014
07/07/2014
06/07/2014

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the most effective way to retrieve the slug value from an array of objects that matches a given id?

I am currently working on extracting the slug value from an array within the object.extra.services. The goal is to find the element in this array that matches the ID I provide... // Service ID provided const serviceID = '5cdd7c55f5abb90a689a44be&apos ...

Ways to adjust .keyup based on the presence of a variable

I am currently in the process of constructing a search form that utilizes an ajax function within .keyup, which may have various arguments. I aim to determine if a specific argument should be included based on the presence of another value. Here is my curr ...

Switching between images with a simple click in various locations

I'm currently working on implementing an accordion feature where I am using custom arrow icons (pngs) as the toggle buttons. The idea is that when you click on the red down arrow, it changes to a blue up arrow to collapse the section, and vice versa. ...

What is the best way to remove a specific element from an array?

Imagine you have an array with 5 items, each containing objects. To visually represent this, elements must be created in the document according to the length of the array. Here's how: let array = [ { "value": "Hello" }, { "value": " ...

Organizing dynamic arrays using ECMAScript 2015

Currently, I am manipulating and reordering an array using data from a webpage. Initially, I reordered my array of objects based on a separate "sorting array" order. The original array looked like this: [ { "domain":"www.exampleurl.com/redire ...

Tips for binding to a single input box within an ngFor loop

Can anyone lend a hand with some code? I'm working on a straightforward table using ngFor, but I'm facing an issue with input binding. The problem is that all the input fields generated by ngFor display the same value when typing. How can I preve ...

Transmit a collection of images in JSON format from a Node.js server

Greetings, fellow listeners and callers! :-) As a newcomer to the world of nodejs and javascript, I am finding it challenging to grasp the event and callback model. My objective is to generate and return a JSON array containing information about photos ( ...

Focusing on pinpointing certain mistakes within Drupal 7

When working with Drupal, encountering errors is a common issue. While some errors are simple to fix, others can be quite complex and require significant time and effort to resolve, even if the website appears to function normally despite the error. My qu ...

Utilizing DomQuery in TinyMCE for element retrieval

I'm currently working with TinyMCE to develop a WYSIWYG editor, however, I've encountered an issue that has me feeling stuck. My goal is to establish a system where users can create specific documents, each divided into sections as wrappers. Wit ...

React - issue with modal due to invariant violation

In my application, I have implemented a modal with a dropdown menu containing various Categories. Upon selecting a Category, a new dropdown menu appears which displays Classifications. If a Classification is selected, another component is rendered on the p ...

Guide to exporting specific files in Node.js or Deno

Utilizing the export keyword in JavaScript allows us to export any content from one file to another. Is there a way to restrict exports to specific files, preventing other files from importing them? export const t = { a: 'this will only be exported fo ...

Maintain a sticky position with a set minimum distance from the bottom of the container

How can I position content in a container with some minimum distance to the bottom? Specifically, I want the blue element to stop before reaching the very bottom of the container. I could stack two containers on top of each other and only include the stic ...

Can you explain the purpose of the datalayer.push function?

I've been puzzling over this.. It seems like data layer.push is simply updating the second amount. Can someone shed light on what exactly is happening here? function dollarz() { var amount1 = '$156.86'; var amount2 = amount1.replace(&quo ...

Using PHP to set cookies after making an AJAX request

After reviewing numerous posts on this topic, I am still unable to set any cookies with my code. The initial ajax call in my code looks like this: $("#loginForm").submit(function(event) { event.preventDefault(); var uid = document.getElementById( ...

Differences between JavaScript's window.onload and body.onload functionsWhen

My inquiry is similar yet slightly distinct from the one queried here: window.onload vs <body onload=""/> The comparison in that prior query was between utilizing window.onload and inline js. My question pertains to the disparity between ...

The elements within the Popup Modal are not displaying as expected

I found a helpful tutorial that teaches how to display a Popup Modal Window when the page loads. However, I'm facing an issue where the modal is not showing the contents and images properly. The code I am working on can be found at jsFiddle. My goal ...

Shutting down Worklight application upon tapping using SIM card information

As I work on developing an IBM Worklight application, one of my tasks involves checking the SIM details before launching the app. The code snippet below demonstrates this process: function wlCommonInit() { WL.Device.getNetworkInfo(function(networkI ...

Using Axios to retrieve data from a MySQL database is a common practice in web development. By integrating Vue

I have developed another Vue.js admin page specifically for "writer" where I can display post data fetched from a MySQL database. The admin page called "admin" is functioning properly and responding with all the necessary data. The following code snippet ...

ChartJS is exhibiting an issue within a modal or popup window where the chart is being displayed with a height

I want to show a graph in a modal window when the user clicks a button. The modal is hidden with display: none;, and becomes visible with display: flex; once the button is clicked. If I move the chart outside of the modal, it works without any issues. Ad ...

Submitting data in an android app using the HTTP POST method and

I need to translate this HTTP POST request from JavaScript to Android. I'm facing an issue with cids: []. I am unable to create a JsonObject with the square brackets symbol [ ] as it should be an empty array. This is my original JavaScript code: va ...