fork(2) download
  1. <?php
  2. $arr = array(
  3. "2016-03-03 19:17:59",
  4. "2016-03-03 19:20:54",
  5. "2016-05-03 19:12:37"
  6. );
  7. foreach($arr as $key => $date)
  8. $arr[$key] = date("Y-m-d", strtotime($date));
  9.  
  10. print_r($arr);
  11.  
  12. $arr = array(
  13. "2016-03-03 19:17:59",
  14. "2016-03-03 19:20:54",
  15. "2016-05-03 19:12:37"
  16. );
  17. function format_date($val) {
  18. $v = explode(" ", $val);
  19. return $v[0];
  20. }
  21. $arr = array_map("format_date", $arr);
  22.  
  23. print_r($arr);
Success #stdin #stdout 0s 52488KB
stdin
Standard input is empty
stdout
Array
(
    [0] => 2016-03-03
    [1] => 2016-03-03
    [2] => 2016-05-03
)
Array
(
    [0] => 2016-03-03
    [1] => 2016-03-03
    [2] => 2016-05-03
)