How to make a nice date picker in PHP

0 votes
As I play about with MySQL and PHP, I'm interested in making a good "date picker," such as selecting the date 2010-11-11 (today's date).

 In order to avoid making the user fill out dates manually in a form and then perform validation, I want to keep correct DATETIME values in my MySQL database and want a PHP page to offer rolling lists for the year, month, and day (for example, 2010-11-11).

My issue is: How can I make the simple rolling lists so that they can adjust dynamically if, for example, the user selects the date 2010-11-31 (which doesn't exist)? In other words, the user selects the year, the month, and then the day (which is dynamically altered to accommodate the actual number of days in the given month). I'm hoping that leap years will also be taken into account. When the user selects "Submit" after selecting all of them, the script will send the database a DATETIME value that is correctly structured (e.g. YYYY-MM-DD, or YYYYMMDD).

I believe the DATETIME type to be strict by default, which means the server will keep note of invalid dates that should be rather simple to error-check. But by doing what I just outlined, I wish to avoid this.

Would you deem my proposed "solution" simple to put into use with just PHP (and MySQL)? Or would I need other software (like JQuery, AJAX, or JavaScript) to manage this? Any advice and pointers are welcome, especially different methods to the same issue that could be simpler to put into practice. I appreciate it.
Aug 8, 2022 in PHP by Kithuzzz
• 38,010 points
1,280 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In PHP

0 votes
1 answer

How to implement a callback in PHP?

Hello, Implementation of a callback is done like ...READ MORE

answered Apr 15, 2020 in PHP by Niroj
• 82,880 points
655 views
0 votes
1 answer

How can I connect to a Tor hidden service using CURL in PHP?

Hello @kartik, I use Privoxy and cURL to scrape Tor ...READ MORE

answered May 19, 2020 in PHP by Niroj
• 82,880 points
4,930 views
0 votes
1 answer

How do I convert a PDF document to a preview image in PHP?

Hello @kartik, You need ImageMagick and GhostScript <?php $im = new imagick('file.pdf[0]'); $im->setImageFormat('jpg'); header('Content-Type: image/jpeg'); echo ...READ MORE

answered Aug 14, 2020 in PHP by Niroj
• 82,880 points
4,289 views
0 votes
1 answer

How to convert a string to date in mysql?

Hello @kartik, you can do SELECT STR_TO_DATE(yourdatefield, '%m/%d/%Y') FROM ...READ MORE

answered Aug 20, 2020 in PHP by Niroj
• 82,880 points
2,224 views
0 votes
1 answer

How to resolve the problem of losing a session after a redirect in PHP?

Hello @kartik, Carry out these usual checks: Make sure session_start(); is ...READ MORE

answered Aug 24, 2020 in PHP by Niroj
• 82,880 points
32,871 views
0 votes
1 answer

How do I make a redirect in PHP?

Hello @kartik, Use the header() function to send an HTTP Location header: header('Location: '.$newURL); Contrary to ...READ MORE

answered Sep 16, 2020 in PHP by Niroj
• 82,880 points
509 views
0 votes
1 answer
0 votes
0 answers

Anyone can help me out to understand the semantic of (document.getElementBYId("demo").innerHTML="Hello") ?

Hello guys, Can Someone helps me to find ...READ MORE

Jan 17, 2020 in Web Development by anonymous
• 37,510 points
748 views
+1 vote
1 answer

What is the relationship between angularjs Scope with controller/view?

Let us consider the below block: <div ng-controller="emp"> ...READ MORE

answered Jan 20, 2020 in Web Development by Niroj
• 82,880 points

edited Jan 21, 2020 by Niroj 803 views
0 votes
1 answer

What is data binding in AngularJS?

Data binding is synchronization of data between the ...READ MORE

answered Jan 23, 2020 in Web Development by Niroj
• 82,880 points
847 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP