php - Calculate remaining days -


I have a school project where I have to make an agenda. I am having problems with my calculation function, so the work given below is required to calculate the remaining days after the next day's appointment. I have a future date ($ timefromdb) stored in my mysql database and I I want to calculate the difference between the current date and date from the database. public function getAllAfspraken () {$ db = new Db (); $ Sql ​​= "SELECT * FROM` tblafspraken`"; $ Return = $ db- & gt; Conn- & gt; Query ($ sql); While ($ line = mysqli_fetch_array ($ return)) {$ currentdate = date ("Y-M-D"); $ Timefromdb = $ line ['af_datum']; $ Timeout = $ current-time- $ timframedb; $ Daybound = round (($ Time-Left / 24) / 60) / 60); Echo "& lt; h3 & gt;" $ Line ['af_datum']. "& Lt; / h3 & gt;"; Echo "& lt; p & gt;" . $ Line ['af_beschrijving']. "& Lt; / p & gt;"; Echo $ day left; Echo "& lt; hour / & gt;"; }}

for the calculation date time: difference Use

  $ date1 = new date time ("2014-04-30"); $ Now = new dateTime (); $ Diff = $ date1- & gt; Different ($ now); Echo 'remaining day ::' $ diff- & gt; day;   

will show up on + ve or -ve

you $ diff-> gt; You can also use the format ('% R% a day'); for + ve or -ve

  // print_r ($ diff); The complete data for   

$ diff is as follows and you can find a difference on various parameters like day, hour, minute etc.

  Date interval object ([y] => [[m] => [[]] => 4 [H] => 10 [i] = & Gt; 3 [S] = & gt; 46 [Weedday] = & gt; [[Vade_bihar] => [[First_ last_day_of] => [[Convert] => 1 [days] = & gt; Gt; 4 [special_type] = & gt; 0 [special_mount] => [[has_weekday_relative] => [[has_special_relative] => 0)    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -