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
2
Answers
Please refer to the issue below.
Try lowercase
yyyy
rather than uppercaseYYYY
?how to convert current date to YYYY-MM-DD format with angular 2
There are 2 issues :
You’re using
YYYY
which is the "week numbering year", you need to useyyyy
DD
has no value, you need to usedd
to get the date.