The format YYYY-MM-DD is invalid and cannot be used

When referencing the Clarity Design documentation for datepicker at this link, it is mentioned in the last section titled Summary of Options that the format for [max] should be in YYYY-MM-DD.

In the code snippet below, I have set the maxDateLimit to the same format. However, upon running the code, I encountered the error logs as shown in the screenshot.

Am I incorrectly using the YYYY-MM-DD format? Please advise on why this error is occurring and how to rectify it.

Code:

private onSatelliteTimeRangeFromSet(event:any):void {
console.log(this.debugTag,"dateOfSpray: ", this.iDatePasser.dateOfSpray)
const splitted = this.iDatePasser.dateOfSpray.split('/')
const numOfDateBites = splitted.length
this.maxDateLimit = this.datePipe.transform(new Date(), 'YYYY-MM-DD') as string
const maxDateLimitAsDate = new Date(this.maxDateLimit)
const dateOfSprayAsDate = new Date(this.iDatePasser.dateOfSpray)
const maxDateDate = maxDateLimitAsDate.getDate()
const maxDateMonth = maxDateLimitAsDate.getMonth()
const maxDateYear = maxDateLimitAsDate.getFullYear()

console.log(this.debugTag,"maxDateLimit: ", this.maxDateLimit)

Logs:

https://i.sstatic.net/sNIbD.png

Answer №1

Kindly look into the matter outlined below.

Have you considered using lowercase yyyy instead of uppercase YYYY?

how to transform current date into YYYY-MM-DD format with angular 2

Answer №2

Here are a couple of issues :

  • You have YYYY instead of yyyy, which represents the "week numbering year". Make sure to use yyyy.

  • The variable DD is missing a value, you should be using dd to retrieve the date.

Answer №3

give this a shot

  1. convert DD to dd (lowercase)
  2. switch YYYY to yyyy (lowercase)

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

Issue with clientHeight not functioning properly with line breaks in Angular 2 application after ngAfterViewInit

I have successfully created a Gridify page in my Angular 2 application using the Gridify library. To initialize it, I've utilized a custom ngAfterViewChecked method: ngAfterViewChecked() { var selector = document.querySelector('.read-grid& ...

Utilizing JavaScript to trigger an email with PHP variables included

i am trying to pass a few php variables using a javascript trigger. Everything seems to be working with the variables, databases, and script but I am struggling with the PHP part. Here is my attempt at the PHP code, although it clearly has some issues. I ...

A guide to leveraging React.lazy within your Gatsby projects

When attempting to use React.lazy in Gatsby for production by running gatsby build, errors may arise. What would be the most effective approach to implement React.lazy and suspense in a Gatsby Project? ...

Tips for grouping radio buttons that span multiple rows within an ag-grid

I am currently working on a grid layout that consists of multiple rows, with each row containing a radio button as illustrated in the snapshot below: https://i.sstatic.net/O8i0r.png Here is the code snippet for the column definition of the radio button: ...

Implementing closure within a recursive function allows for better control

One of my functions is designed to take a parameter and print the last number in the Fibonacci Series. For example, if the parameter is 3, it would return 2 as the series progresses like 1, 1, 2. function recursionFib(num){ if(num ...

Copying the label for data to a jQuery array can be done by selecting the desired label

Allow me to clarify I am attempting to create a jQuery array containing values copied from a form field. Below is a snippet of the HTML code. <p class="form"> <input id="Dataweekend0" class="radiob" name="form[Dataweekend]" ...

Comparing Encrypted Passwords with Bcrypt

Encountering an issue with comparing passwords despite accurately storing the hashed password during registration. Database - MongoDB Node.js version - v18.17.0 Bcrypt version - 5.1.1 Below is my userSchema: const userSchema = new mongoose.Schema({ u ...

Issue with navigating through JSON data

Here is the JSON data I have: { "GetCommentsByPostResult": [ { "CommentCreated": "\\/Date(1305736030505+0100)\\/", "CommentText": "Comment 1" }, { "CommentCreated": "&bsol ...

avoiding browsers loading files that are dropped outside of the designated drop area

Currently, I have set up file drop functionality using ng2 file upload. The issue I am encountering is that when a file is dropped outside of the designated drop area, the browser automatically opens it. Is there a solution to prevent this from happening ...

Learn how to locate and substitute every designated character instance, whether using C# or regex. Discover the process of converting code from Javascript to C#

Locate and substitute the 3rd instance of each character in a given string with H For example: 74Mercedes1980 would become 74HerHedHs1H80 This task can be accomplished using C# or regex. I have come across a Javascript script that achieves this, but I a ...

When the if statement fails to halt the code from running

After diving into the world of coding just one or two weeks ago, I decided to create a feature where users can press a key to start playing. No matter what I try, I always end up with the same outcome. Here's my approach: I have an if statement that ...

Developing an ASP application using the MVP pattern to return JSON data can be transformed into a S

I’m looking to incorporate the following code into a sails js Controller public JsonResult GetEvents() { //Using MyDatabaseEntities as our entity datacontext (refer to Step 4) using (MyDatabaseEntities dc = new MyDatabaseEntities()) { ...

Loop within a promise results in undefined

Within my application, there is a function that returns a promise. Inside this function, I wait for an image in the DOM to become available and then extract that element to generate base64 data from it. getCodesOfOneMerchant(merchantDataEntry: MerchantData ...

Manipulate the default option in a Select field with JavaScript

I'm currently working on a WordPress post editing page and I need to set up a target link: By default, the option is set to "None", but I want to change it to "Custom Link..." with the following details: <select name="imt_team_href" onchange="imt ...

Is it possible to receive real-time updates for a specific location in Cesium

I am currently developing a live tracking application using Cesium, and I'm encountering an issue with updating the point location on the map in real-time. Currently, my Cesium viewer successfully receives the data from the server in JSON format and ...

Error message: "No such file or directory found for Angular ng"

Recently, I encountered an issue while attempting to host an Angular app on a server. When using the command ng serve, it returned an error stating "No such file or directory," despite the fact that the ng command is visible in the image below. https://i. ...

Attempting to execute the command "ionic serve" results in the display of various error messages

When attempting to run “ionic serve”, I encountered the following errors: [ERROR] ng has unexpectedly closed (exit code 127) https://i.sstatic.net/xgeb7.jpg Thank you in advance. ...

You are unable to use multiple background colors on a material UI snackbar

Is there a way to apply multiple background colors to a material UI snackbar? I attempted using linear-gradient as shown below, but it didn't work. import Snackbar from 'material-ui/Snackbar'; const bodyStyle = { border: `2px solid ${co ...

Is your Firebase Google sign-in popup window flashing and not successfully signing in while using Vue.js?

After implementing the Google sign-in pop-up method in Vue.js, I encountered an issue where the live Google sign-in popup window kept flashing and never successfully signed in. However, this problem did not occur when testing locally. Below is the code fo ...

What is the best way to filter and sort a nested tree Array in javascript?

Looking to filter and sort a nested tree object for a menu If the status for sorting and filtering is true, how do I proceed? const items = [{ name: "a1", id: 1, sort: 1, status: true, children: [{ name: "a2", id: 2, ...