Help me please...
I want to insert all dates and days name in one year automatically. for example : 2017. I want to insert into table from 01-01-2017 to 31-12-2017 automatically.
Help me please...
I want to insert all dates and days name in one year automatically. for example : 2017. I want to insert into table from 01-01-2017 to 31-12-2017 automatically.
Something like this.
with getFullYear().
for (var d = new Date(2017, 0, 1); d < new Date(2018, 0, 1); d.setDate(d.getDate() + 1)) {
var input = $("<input>");
input.val(d.getFullYear());
$("#year").append(input);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="year">
</div>
PHP way to do this:
$startDate = new DateTime('2017-01-01');
$endDate = new DateTime('2018-01-01');
while($startDate < $endDate){
echo $startDate->format('d-m-Y'); //print date with format day-month-year
echo "\n";
$startDate->add(new DateInterval('P1D')); //add 1 day
}
Output:
01-01-2017
02-01-2017
03-01-2017
04-01-2017
...
31-12-2017