Struggling with formatting an array of dates and receiving unexpected output

I have a task of formatting dates within an array. I attempted to achieve this by running a forEach loop and using moment format, but unfortunately the results turned out to be invalid.

response =  [
        {
          "type": "blackout",
          "dates": ["2019-12-31T17:52:30.263Z", "2020-11-21T17:52:30.263Z", "2020-11-22T17:52:30:263Z"],
           "description": "Blackout Period"
        }..........................................................................................]



 response.forEach( items => {

     const dates =   moment(items.dates).format('YYYYMMDD');

     console.log(dates, "dkjedjedkjed");
      });

Here is the link to StackBlitz. I tried one solution but encountered some issues with certain dates appearing as invalid. https://stackblitz.com/edit/angular-hxmkkd

Answer ā„–1

Is there a mistake? The incorrect dates are formatted using a colon (:) instead of a decimal point (.) as the separator for milliseconds:

"dates": ["2019-12-31T17:52:30.263Z", "2020-11-21T17:52:30.263Z", "2020-11-22T17:52:30:263Z",]

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

Test the functionality of clicking on buttons in a specific order within a given set

I need assistance with a unique task involving a series of buttons in my Intern functional test. Each button needs to be tested sequentially, but I'm not sure how to go about it. In my code snippet below, you can see the structure of my page: <inp ...

The clearing of sessions is not supported by Node.js / Express.js

At the start, the application loads some users using Angularjs / $http.get(). As you scroll down, more users are loaded dynamically (infinite scroll). In addition to this, there are location filters on the page. Users can select a different Country and Ci ...

Error: Unexpected 'else' statement found inside a <form> element

Hey everyone, I'm a new programmer and I appreciate your patience as I ask what might seem like beginner questions. I started learning programming just a few days ago. Currently, I am working on creating a basic form with username/password fields and ...

The eternal Three.js animation that loops endlessly whenever it is clicked

The Objective My aim is to create a straightforward camera zoom in animation that increases the zoom level by a specific amount each time the button is clicked. The Current Status I have successfully implemented the animation using Three.js and linked i ...

How can I prevent users from registering with the same username in a PHP/MySql user registration system?

I am currently developing a website and need to ensure that each user has a unique username and password. My web page is already connected to a database, which includes fields for users to input their information such as name, username, password, etc. I r ...

PHP is throwing an error because of a missing parenthesis in the argument list

Displaying data from PHP with a tag, here is the code: echo '<a class="ui label" onclick="variant_desc('.$product_id.');"> '.$variant->Field1.' </a>'; When I click the function mentioned in the tag, I get the ...

Update a parent page section with new content once a child modal popup is closed

I've hit a roadblock with this problem and despite trying several solutions, I can't seem to get it right. Within my MVC6 view, there are multiple partials. One of the partials contains an anchor tag: @model ModelA <div> @Html.TextBoxF ...

html2canvas is functional for some tasks while ineffective for others

I'm facing an issue that I just can't seem to wrap my head around... So, in an attempt to solve this problem, I decided to use html2canvas.js. My goal is to convert HTML content into an image. Everything seems fine when the content is within a m ...

Angular - Conceal Protected Links on the Template

In my AuthGuard, I have implemented CanActivate which returns either true or false based on custom logic: import { Injectable } from '@angular/core'; import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular ...

Adjust the appearance of the initial row within a table

Is there a way to directly change the CSS style of the first row in a table when a checkbox is checked? I am facing an issue where the style does not apply correctly, and I need assistance in targeting the first row specifically with CSS. Essentially, eve ...

What are some strategies for getting neglected distribution files onto Bower despite being ignored by git?

I am in the process of creating a package for NPM and Bower. To maintain organization, I store my working files (ES6) in the src/ directory of the package and compile the distribution files (ES5, using Babel) in the lib/ directory. For version control, I ...

Display real-time export status improvement

Utilizing the Java Script below to display a loader once the Export To Excel button is clicked. <script type="text/javascript"> function showProgress() { var updateProgress = $get("<%= UpdateProgress1.ClientID %>"); updateP ...

Mutex in node.js(javascript) for controlling system-wide resources

Is there a way to implement a System wide mutex in JavaScript that goes beyond the usual mutex concept? I am dealing with multiple instances of a node.js cmd running simultaneously. These instances are accessing the same file for reading and writing, and ...

Issue: No property named 'counterUp' has been defined on the 'JQLite' type

Iā€™m attempting to implement the counterUp() function from JQuery into my Angular project, but I keep encountering an error. The error message mentions jqlite instead of jquery. I have attempted to rectify the issue but have not been able to find a su ...

Is there a way to retrieve information from an external URL in JSON format and display it using JavaScript on a separate HTML webpage?

I'm trying to display the value TotalPostNotificationCount from a JSON file in an external HTML using either JavaScript or PHP. The JSON data is as follows: { "DayPostCount": 1, "TotalPostNotificationCount": 7381 } This data can be found at t ...

Experimenting with Nuxtjs application using AVA and TypeScript

I'm in the process of developing a Nuxt application using TypeScript and intend to conduct unit testing with AVA. Nonetheless, upon attempting to run a test, I encounter the following error message: āœ– No test files were found The @nuxt/typescrip ...

The 'google.maps' namespace does not export the 'MouseEvent' member after installing @agm/core and @types/google

When attempting to install @agm/core and @types/google maps, I encountered the following errors: node_modules/@angular/google-maps/map-polyline/map-polyline.d.ts:42:45 - error TS2694: Namespace 'google.maps' does not have an exp ...

I am experiencing issues with the rendering of my q-btn elements in Quasar and they are

I recently started using Quasar and encountered an issue with my q-btn component buttons displaying white backgrounds at random, despite having added a background-color in the external stylesheets. Here are some examples of this perplexing problem: https ...

calling the setState function multiple times

I keep calling the setState function multiple times in a row by pressing the down button, but I noticed that React JS stops updating the state after around 40-50 updates. Each click increases the sold value by one. Is this normal behavior for React JS, or ...

Despite having installed NPM, the system is still unable to recognize the command, displaying the message: 'CALL "C:Program Files odejs ode.exe" "C:Program Files odejs ode_modules pmin pm-prefix.js"'

Having a problem with npm on my Windows computer. Whenever I type npm --version in the command line, I see the following message: C:\\Users\\nares\>npm --version 'CALL "C:\\Program Files\\nodejs&bso ...