Trying to create a picker in Javascript where I can get the date out of (and the time, eventually). I have made it in jsfiddle: https://jsfiddle.net/ariley/ej37qv5w/18/
Here’s the JS part of the code:
const picker = new Picker(document.querySelector('.js-inline-picker'), {
controls: true,
inline: true,
increment: {
year: 1,
month: 1,
day: 1,
hour: 1,
minute: 15,
},
format: 'YYYY/MM/DD',
date: new Date(), // default to today's date
text: {
title: 'Pick a date',
},
});
// Listen for when a date is selected
picker.getDate('pick', function(date) {
// Date is picked. Let's store it!
const selectedDate = date.format('YYYY/MM/DD');
console.log('Selected Date:', selectedDate); // Or do whatever you wish with it
// Example: Storing in localStorage
localStorage.setItem('selectedDate', selectedDate);
});
I’m unable to get the date, but there are no errors. What am I doing wrong?
Thank you!