yagrasdemonde Posted November 18, 2014 Share Posted November 18, 2014 Hello,I'm very disapointed because I don't know how do it this.I'm explain.I have a database with one input date_arrival and second date_departure.Two dates are saved in SQL format : 2014-03-02.After my SQL request to select all dates in database I'd like to add dates between date_arrival and date_departure and for each line.For example I havedate_arrival date_departureline 1 : 2014-02-01 2014-02-05line 2 : 2014-02-10 2014-02-15In fact at the end, I have to send the result like this (with JSON) :["2014-02-01","2014-02-02","2014-02-03","2014-02-04","2014-02-05","2014-02-10","2014-02-11","2014-02-12","2014-02-13","2014-02-14","2014-02-15"] Can you give me some help to add intermediates values in an array ?Thx Quote Link to comment https://forums.phpfreaks.com/topic/292537-date-range-and-array/ Share on other sites More sharing options...
Ch0cu3r Posted November 18, 2014 Share Posted November 18, 2014 (edited) You can use the built in DateTime class to generate the dates between the start and end dates Look at the DatePeriod examples here http://php.net/manual/en/dateperiod.construct.php To encode the dates into JSON add each date to an array and then use json_encode Edited November 18, 2014 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/292537-date-range-and-array/#findComment-1496877 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.