Currently my api link is dynamic by selecting the current year and month.
Example:
APILINK…/202109
That part is fine… But what I want to do is change the last part of the API link (Year and Month) with a datepicker and I’m not sure how I can do that.
My current Code:
const timehsheetUrl = "API LINK"
const today = new Date();
const date = today.getFullYear()+('0' + (today.getMonth() + 1)).slice(-2);
const settings = {
"async": true,
"crossDomain": true,
"url": timesleetUrl + date,
"method": "GET",
"headers": {}
}
2
Answers
It’s easy use jQuery date picker.
On date select script should return selected date’s month and year.
Store the output in variable and format. The code shown below will help you
No, you don’t need to use datepicker plugin, while plugin is more convenient.
Here’s an example with default HTML date-input.