Troubleshooting the issue with formatting dates in AngularJS

I need help converting 2015-04-17 12:44:38.0 to dd/MM/yyyy format using angularjs

<td ng-bind="item.MON_FE_DUEDATE | date:'dd-MM-yyyy'"></td>

However, it is still displaying 2015-04-17 12:44:38.0 only. Can anyone please point out where I went wrong?

Answer №1

Because you are attempting to format it as a string.

Check out the functional fiddle.

https://jsfiddle.net/p7gz0opm/

Transformed the string into a Date.

function MyCtrl($scope) {
    $scope.date = new Date('2015-04-17 12:44:38.0 ');
}

Template:

<div ng-app ng-controller="MyCtrl">
    {{date | date:'dd-MM-yyyy'}}<br />
    {{date}}    
</div>

Edit :

In this scenario, you will need to go through a function. Take a look at another fiddle.

https://jsfiddle.net/qjs1uj37/

$scope.parth=function(str){
        return new Date(str);
    }

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

Efficient JSON Parsing using Volley and GSON

Currently, I am attempting to extract JSON data from the following URL: I have developed a POJO for Gson and integrated a Volley-based class into my application. The goal is to parse JSON objects into my listview using a custom adapter. Below is my Voll ...

Splitting JSON data into groups using Python 3

Looking to divide the actual value into separate dynamic groups represented as an array of objects. c = { 'Date#1': '07/03/2018', 'Item#1': '789807', 'Description#1': 'Wooden Block ...

React - Utilizing Secondary Prop Value in Material UI Node Components

I've been working on streamlining my code and am wondering about the best way to pass an additional value using props while fetching data from the backend. I'm utilizing material UI's Autocomplete with the PERN stack. Everything is functioni ...

Exploring the power of Django testing, managing transactions effectively, and automating browser

For my backend, I rely on django-rest-framework and for the frontend, I use angularjs. Recently, I started implementing e2e tests using protractor and encountered an issue where all changes in the database were being saved after each test. In django, eve ...

Having trouble installing sqlite3? Encounter an issue like this: "srcdatabase.cc(35): error C2248: 'Napi::Env::DefaultFini': cannot access private member declared in class 'Napi::Env'"?

Encountering issues while trying to install sqlite3 for a Strapi app I've attempted using yarn to install sqlite3 in various ways, but to no avail. Below is the error log: Error message: Issue with installing sqlite3 when creating a Strapi app (..& ...

Create a loop in JavaScript to iterate through elements using both a while loop and the

I have a JSON object (returned by the server) and I am looking to iterate through it with either a while loop or forEach method in order to display the products in a shopping cart. The name of my object is response2, which contains the cart products. I w ...

Following the submission of a message, the textarea automatically inserts a line-break

Can someone please help me troubleshoot an issue with my chat app? Every time I try to send a message, the textarea adds a line break instead of just focusing on the textarea so I can send a new message smoothly. I have recorded a video demonstrating the ...

What happens when a JavaScript variable is used inside the $.ajax function and returns null?

I've come across numerous questions that are similar to mine, but unfortunately, I haven't been able to find a solution! My issue involves attempting to open a PHP file while passing certain Javascript variables into the URL using $.ajax. However ...

Support for Chrome in Angular 8

Can someone please advise on the minimum version of Google Chrome that is supported by Angular 8? Additionally, I am looking for a way to prompt users to update their Chrome browser if it doesn't meet the required version. My Angular application seems ...

Unexpected Error: Unable to access the 'position' property of an undefined element (D3.JS)

This error occurred when I attempted to fetch JSON data and convert it into a line graph. An unexpected TypeError was thrown: Unable to access the 'position' property of undefined Below is the relevant portion of the JS code: d3.json("../js/ ...

Creating a multi-level mobile navigation menu in WordPress can greatly enhance user experience and make

Hey there, I am currently in the process of developing a custom WordPress theme and working on creating a mobile navigation system. Although I have managed to come up with a solution that I am quite pleased with after multiple attempts, I have encountered ...

Having trouble connecting DB and D3 using PHP. Struggling to follow D3noob's tutorial to completion

First and foremost, I want to express my gratitude to the amazing community here for all that I have learned. However, I'm currently facing some difficulties in finding the solution I need. I've encountered issues while trying to follow the inst ...

What is the best way to apply styling to an image that is contained within the document.write function?

I'm looking to customize the design of this cat image, but I'm struggling to locate where to incorporate the div class. It's likely a basic step, but as a beginner in JavaScript, I'm hoping that someone can assist me. document.write(&ap ...

CSS modified after opening a modal dialog that has loaded external HTML content

Within my ASP.NET MVC project, I am utilizing a tab wizard. On one of the tabs, I trigger a modal dialog by loading HTML content from an external API. However, once I close the wizard and navigate to the next tab, the table style (specifically border color ...

Can a web application be developed utilizing JavaScript to access the torch feature in Safari?

Currently working on a website that needs to utilize the flashlight feature on both android and IOS devices. Found a method to activate the torch from an android device using Chrome (link). However, this same code does not seem to be functional on my IOS d ...

What is the best way to ensure that my $.ajax POST call works seamlessly with SSL?

Below is the JavaScript code I am using: parameter = "name=" + name + "&email=" + email + "&phone=" + phone + "&comments=" + comments; $.ajax({ url: 'sendEmail.php?' + parameter, success: ...

Pandas: The ultimate tool for creating custom multilevel JSON responses

Looking to transform the data output below into a pandas dataframe with specific columns: List (whitelist, blacklist) QueryWord (gun, trench concrete, tripod....) ContextWord (1, 2, 3, 4...) Score (0.1, 0.2....) api_output = {"whitelist": ...

Arrange a JSON file by organizing a key located within an array of dictionaries using Python

Here's a structure that I am working with: [{ "name": "apple", "price": "5.0", "record": [ { "id": "008", "time": 1465689600 } ] },{ "name": "banana", "price": "9.0", "record": [ ...

When using Material UI TextField with input type "date", the event.target.value does not seem to be accessible

I am currently working with Material UI and React Grid from DevExtreme to build a table that includes an input field of type date. However, when I attempt to enter the date, it does not register the change in value until I reach the year field, at which po ...

How can I leverage Express, AngularJS, and Socket.io to facilitate broadcasting and receiving notifications?

A new notification system is in the works. To illustrate, User 1 is initiating a friend request to User 2. The technologies being utilized include express.js, angularjs, and socket.io. When User1 clicks the button, a request is sent. On User2's end, a ...