skip to Main Content

referring to this link:https://clarity.design/documentation/datepicker
in the last section titled Summary of Options, it states that, for example, [max] should be in YYYY-MM-DD formate.

as shown in the below posted code, i set the same format to maxDateLimit. but when run the code, i receive the logs shown in the screen-shot.

Am I using YYYY-MM-DD wongly? please let me know why i am getting this error and how to fix 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

enter image description here

2

Answers


  1. Please refer to the issue below.

    Try lowercase yyyy rather than uppercase YYYY?

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

    Login or Signup to reply.
  2. There are 2 issues :

    • You’re using YYYY which is the "week numbering year", you need to use yyyy

    • DD has no value, you need to use dd to get the date.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search