Proper date formatting in Angular Data Table

Could anyone help me with date formatting? I am facing an issue with the date format in a table within my application. The current date format is not correct and appears as shown on the screen. I would like to format it to YYYY-MM-DD only. Any suggestions or advice?

View the screen from the console

appManagementProjects.js

(function() {
'use strict';

angular
    .module('appManagementProjects', [
        'ngMaterial'
    ])
    .controller('ManagementProjectsCtrl', ManagementProjectsCtrl);

function ManagementProjectsCtrl(serviceManagementDataTable, serviceManagementProjects, $mdDialog, $mdToast) {
    var vm = this;
    // more code here...
}
})();

serviceManagementProjects.js

(function() {
'use strict';

angular
    .module('appManagementProjects')
    .factory('serviceManagementProjects', ServiceManagementProjects);

function ServiceManagementProjects($resource) {
    var data = [];
    // more code here...
}
})();

addDataProject.html

<md-dialog class="md-default-theme addProjectForm">
<md-dialog-content>
    <h2 class="md-title">Adding a new project</h2>
    <form name="addProject" onclick="return false;">
        // form fields here...
    </form>
</md-dialog-content>
<div class="md-actions">
    // buttons here...
</div>

editDataProject.html

<md-dialog class="md-default-theme addProjectForm">
<md-dialog-content>
    <h2 class="md-title">Editing a project</h2>
    <form name="editProject" onclick="return false;">
        // form fields here...
    </form>
</md-dialog-content>
<div class="md-actions">
    // buttons here...
</div>

managementProjects.html

<div management-data-table datatable="managementProjects.dtData" columnstable="managementProjects.dtColumns" config="managementProjects.config"></div>

datatable directive

(function() {
'use strict';

angular
    .module('appManagementDataTable')
    .directive('managementDataTable', ManagementDataTable);

function ManagementDataTable($mdDialog) {
    return {
        // directive content here...
    }
}
})();

Answer №1

Did you review the date documentation provided by the company?

Additionally, you have the option to adjust the date format in your view by filtering the date property with the 'YYYY-MM-DD' format. Take a look here, OR you can change the date format in your code using

createdDate = $filter('date')(new Date(), 'yyyy-MM-dd')
in your code block createdDate.

I hope this information proves helpful!

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

Notification prompt when removing items

I currently have a table set up with a delete <a> tag that allows users to delete data. I would like to add a confirmation message asking the user if they are sure they want to delete before proceeding. I attempted to achieve this using JavaScript bu ...

Puppeteer and Chromium are ready to go with no need for any configuration

I have a specific HTTP request that I am trying to intercept, but I am encountering issues when chromium is launched through puppeteer. Some flags seem to be causing the requests to not return the expected data. However, everything works fine when I manual ...

Transferring the AJAX response into a JavaScript variable

New to AJAX and JS here. I am implementing an AJAX code that fetches data from a php service. I am trying to figure out how to store the returned data in a JavaScript variable, which I can then display on the UI. Below is my AJAX code snippet: <script ...

The PHP Comet feature is causing the page to experience delays in reloading

Hello, I am working on implementing comet functionality using PHP and jQuery. The comet starts with every page load, but this seems to be causing a significant delay in loading any page on the website, taking about 10 seconds. It appears as though the page ...

Tips for creating a scrolling animation effect with images

I'm currently attempting to create an animation on an image using HTML/CSS. The issue I'm facing is that the animation triggers upon page load, but I would like it to activate when scrolling down to the image. Below is my snippet of HTML: <fi ...

What is the process for creating a sense of distance within a sphere using three.js?

I have a three.js sphere with a textured interior and the camera positioned at the center of it. My goal is to make the texture appear much farther away than it currently does. I attempted to incrementally increase the radius from 4,000 to 180,000, making ...

What are the steps to make React JSX direct to "/profile" and display the profile page?

Throughout my application, I have integrated reach router to facilitate navigation between the different pages. However, I came across a navbar component that I really like and decided to add it to my app. Strangely, clicking on the "to: "/profi ...

What's the most effective method for implementing a stylesheet through Javascript in a style switcher?

I've been tackling the challenge of creating a style switcher for my website. Through utilizing .append() and if and else statements, I managed to make it work successfully. Take a look at the code below: HTML <select name="active_style" id="lol" ...

Utilizing MVC Models to Control Angular Material Checkbox Functionality

I'm getting familiar with the concept of MVC and I've started using MVC5 in combination with angular-material. My goal is to incorporate an MVC model variable with an angular material checkbox (md-checkbox). Below is my code snippet for implemen ...

How to Calculate the Time Interval Between Two CORS Requests Using jQuery AJAX

When using jQuery's $.ajax to make a CORS request to a web service, there is typically a pre-flight request followed by the actual POST request. I have observed that when there is a time gap between making two web service calls, both a pre-flight and ...

jQuery introduces additional elements while parsing HTML code

If you have an HTML string that needs manipulation using jQuery, you may encounter the issue of jQuery adding additional tags to the string. To avoid this problem, you can follow this approach: var html = marked(input); //returns an html string console.lo ...

Kendo Template Function: Angular JS version 1.6

I'm working with a currency column that looks like this: { field: 'INVOICE_AMOUNT_ORIGINAL', title: $translate.instant('invoiceAmount'), format: '{0:n}', template: '#= currency(dataItem.INVOICE_AMOUNT_ORIGIN ...

In JavaScript, not all elements are removed in a single iteration, even if the condition is consistently met

I'm currently attempting to compare two arrays containing multiple objects and remove elements based on a condition. To my surprise, while testing in Chrome's console, I noticed that the first array (arr1) is not being emptied even though I am us ...

Utilize the Google Maps API to align an SVG symbol with the direction of an aircraft's

I have been struggling to update the rotation of the Google Maps API SVG aircraft symbol to display the correct heading as it moves. Although it initially loads with the correct heading, I can't seem to figure out how to dynamically update it. I' ...

What is the best way to create a toggle button that can show more or show less of a text snippet with animation?

Is it possible for someone to assist me with showing a long text partially and providing a "show more" button to reveal the rest, along with a "show less" option, all with some CSS animation? I was thinking of using a font awesome arrow down icon for expan ...

Is there a way to share another person's contact card using whatsapp-web.js?

Is it possible to send a contact card of someone else using whatsapp-web.js, even if the person is not saved in my phone's contact list? I want to send a contact card to someone who is on my phone's contacts, but the contact information I want to ...

What is the process for using express and Postman to send a PUT request and modify a specific field in MongoDB?

I'm struggling to figure out how to use a MongoDB document's id in the route and manipulate the 'balance' field using Postman. Here's what my code currently looks like: My route: router.put('/:id', async (req, res) =&g ...

Utilizing event delegation for JavaScript addEventListener across multiple elements

How can I use event delegation with addEventListener on multiple elements? I want to trigger a click event on .node, including dynamically added elements. The code I have tried so far gives different results when clicking on .title, .image, or .subtitle. ...

Angular.js and DAO design pattern

Admitting my newness to Angular.js and lack of experience with frameworks like Backbone or Knockout, I am venturing into building an application that interacts with a server using a RESTful API. After delving deep into the angular documentation and blog po ...

What is the best way to retrieve the column that comes after a specific column?

I have a specific column and I want to extract the subsequent column in the dataset. nhood,column,variablecolumn Treasure Island,3,5 McLaren Park,1,2 Tenderloin,28,112 Lakeshore,14,8 Chinatown,15,103 Although I know the name of the second column, the na ...