jquery - Parsing Datepicker Data in PHP -


to begin with, have code looks in view:

    <input type="text" class="datepicker" name="start1"> <input type="text" class="datepicker" name="end1"> 

i using start , end date how long person staying in hotel. currently, example, if person chooses may 16, 2014 start date , may 24, 2014 end date, being stored in database 1 row such:

'name of person' 'room number' 'start date' 'end date'

so previous example, stored as:

john doe 100 5/16/2014 5/24/2014

instead of however, want each row represent date such:

john doe 100 5/16/2014

john doe 100 5/17/2014

john doe 100 5/18/2014

and on , forth until 5/24/2014.

my question this, how can parse data can store data such?

this achieved using php's datetime methods.

$from = new datetime('2014-05-16'); $end = new datetime('2014-05-24'); $end = $end->modify('+1 day');   $interval = new dateinterval('p1d'); $range = new dateperiod($from, $interval, $end);  foreach ($range $date) {     $row = array(         'name' => 'john doe',         'room' => 100,         'date' => $date->format('n/d/y')     );     print_r($row); } 

ps: don't store month/day/year please. use day/month/year. confuses heck out of people.

edit: formatting nazi


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -