mysql - PHP - datetime array not converting to linux epoch time -


so here attempting script: pull data mysql database datetimes of events. export resulting rows array. convert datetime array linux epoch time array using following php method:

strtotime();

below script. convert original datetime array epoch time array, i've run simple loop located @ end:

<?php     include("/var/www/html/db config/config.php");     session_start();      $datetimearray = array();     $pastevents = array();     $upcoming = array();     $future = array();      //get data mysql db table     $sql = "select datetime events club = 'moderator'";     $query=mysqli_query($db,$sql);      while($row = mysqli_fetch_array($query, mysqli_assoc)){         $datetimearray[] = $row['datetime'];     }      //convert $datetimearray epoch time     for($i = 0; $i < sizeof($datetimearray); $i++){         $temp[] = strtotime($datetimearray[i]);     } ?> 

pulling data database table array successful. here dump of original $datetimearray pulled database. can see there in fact datetimes present in array events, pulled:

array(7) { [0]=> string(19) "2017-08-14 01:45:00" [1]=> string(19) "2017-08-07 01:45:00" [2]=> string(19) "2017-08-23 01:50:00" [3]=> string(19) "2017-08-28 01:50:00" [4]=> string(19) "2017-09-07 01:50:00" [5]=> string(19) "2017-09-13 01:50:00" [6]=> string(19) "2017-08-10 03:20:00" } 

the problem original array in datetime form not convert epoch time through loop. here dump of $temp array supposed hold converted original array:

array(7) { [0]=> bool(false) [1]=> bool(false) [2]=> bool(false) [3]=> bool(false) [4]=> bool(false) [5]=> bool(false) [6]=> bool(false) } 

as visible, not right converting process. data types booleans reason. sure, tried converting 1 element of original datetime array epoch time same method:

echo strtotime($datetimearray[0]); 

and converted fine.

i'm not sure why converting single element works, running loop through array convert whole thing not. potential solutions or ideas appreciated.

thank you!


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -