John Davidson

Looking for help using php variable date in html

0 comments
Message:


Hi im trying to use this date picker but i want it to allow user to only pick between two dates from php variables min is the earliest pickable date and max is the latest this is one variant of what i have tried but none have worked so far.


Any help is apreciated in advance


    <form>
<label>
Choose your preferred party date (required, April 1st to 20th):
<input type="date" name="party" min="<?= echo date($minLanding)>" max="<?= echo date($maxLanding)>" required>
<span class="validity"></span>
</label>

<p>
<button>Submit</button>
</p>
</form>


My Answer:
You can achieve this by using the min and max attributes in the input tag for the date picker. Here's an example of how you can use PHP variables to set the min and max dates for the date picker:

html



Date Picker with Min and Max Dates










In this example, `$min` and `$max` are PHP variables that contain the earliest and latest pickable dates, respectively. The `date()` function is used to format these dates in the required format for the min and max attributes of the date picker input.

Make sure that the PHP variables `$min` and `$max` are defined and have valid date values before using them in the HTML code. This should allow users to only pick dates between the specified min and max dates.

Rate this post

5 of 5 based on 6809 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us