Jacob
Jacob

Reputation: 103

Why I cant set min value of input type date to today?

I want to set min date to today but it doesnt work.

Can you please correct me?

My code:

echo '<input type="date" name="date" min="'.<?php echo date("Y-m-d"); ?>.'">';

thanks

Upvotes: 3

Views: 1632

Answers (2)

Diogo Santo
Diogo Santo

Reputation: 789

Your date is not being printed into the input.

echo "<input type='date' name='date' min='".date('Y-m-d')."'>";

I also swapped the quotations so you could just use the variable within the echo without involving more.

Test example

Upvotes: 1

Pararera
Pararera

Reputation: 372

You don't need <?php and ?> inside already existing<?php ?> tag.

<?php echo '<input type="date" name="date" min="' . date("Y-m-d") .' ">'; ?>

Upvotes: 6

Related Questions