Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set current date with HTML input type Date Tag

Tags:

html

date

php

I am new in php and i want to set current date in my HTMl date tag

<input type="date" value="Today">

How i can get current date?

like image 248
sunny Avatar asked Jun 23 '15 09:06

sunny


People also ask

How can set input type date in mm/dd/yyyy format using HTML?

To set and get the input type date in dd-mm-yyyy format we will use <input> type attribute. The <input> type attribute is used to define a date picker or control field. In this attribute, you can set the range from which day-month-year to which day-month-year date can be selected from.

How can get current date in textbox in HTML?

You've got the right idea. It's just out of order: <input type="text" name="frmDateReg" required id="frmDate" value=""> function getDate(){ var todaydate = new Date(); var day = todaydate. getDate(); var month = todaydate.


2 Answers

Try using date function as

<input type="date" value="<?php echo date('Y-m-d');?>">
like image 116
Narendrasingh Sisodia Avatar answered Oct 09 '22 05:10

Narendrasingh Sisodia


You need to follow standard Y-m-d format

<input type="date"  name="current_date" value="<?php echo date("Y-m-d") ?>">
like image 23
Meenesh Jain Avatar answered Oct 09 '22 04:10

Meenesh Jain