计算日期相同的数组中的数据并构建图表栏morrisjs

I have the following array

array (    [0] => 2014-06-01 12:45:02
    [1] => 2014-06-01 12:45:03
    [2] => 2014-06-01 12:48:52
    [3] => 2014-06-01 12:50:31
    [4] => 2014-06-01 13:18:49
    [10] => 2014-06-01 13:33:16
    [11] => 2014-06-01 14:20:48
    [12] => 2014-06-01 14:24:44
    [13] => 2014-06-01 15:28:16
    [14] => 2014-06-02 10:50:56
    [15] => 2014-06-02 10:51:07
    [16] => 2014-06-02 18:16:13
    [17] => 2014-06-03 11:20:20
    [18] => 2014-06-03 11:58:46
    [19] => 2014-06-03 11:59:03
    [20] => 2014-06-03 12:00:51
    [21] => 2014-06-03 12:01:21
    [22] => 2014-06-04 19:03:17
    [23] => 2014-06-04 19:06:03
    [24] => 2014-06-04 19:12:03
    [25] => 2014-06-04 21:18:03
)

etc... about 30 records, the idea is to get how many "dates" are "the same" 2014-06-01, 2014-06-02, 2014-06-03... etc... so that can get a final result as:
From date 2014-06-01 you logged (9) times
From date 2014-06-02 you logged (3) times
... etc
and with that information I can build a morrisjs chart bar, but I have no idea how to count the dates... now this data I can latter compare with the "last" month or year... but like I said, I have no idea how to count the records because when I use array_count_values it also check for the time and I don't need the time just the date, and the result is not correct, since it count all of the records not the "group" records from same date..

Thank you for taking the time.

Try something like this :

$data = array (    '0' => '2014-06-01 12:45:02',
    '1' => '2014-06-01 12:45:03',
    '2' => '2014-06-01 12:48:52',
    '3' => '2014-06-01 12:50:31',
    '4' => '2014-06-01 13:18:49',
    '10' => '2014-06-01 13:33:16',
    '11' => '2014-06-01 14:20:48',
    '12' => '2014-06-01 14:24:44',
    '13' => '2014-06-01 15:28:16',
    '14' => '2014-06-02 10:50:56',
    '15' => '2014-06-02 10:51:07',
    '16' => '2014-06-02 18:16:13',
    '17' => '2014-06-03 11:20:20',
    '18' => '2014-06-03 11:58:46',
    '19' => '2014-06-03 11:59:03',
    '20' => '2014-06-03 12:00:51',
    '21' => '2014-06-03 12:01:21',
    '22' => '2014-06-04 19:03:17',
    '23' => '2014-06-04 19:06:03',
    '24' => '2014-06-04 19:12:03',
    '25' => '2014-06-04 21:18:03',
);
foreach ($data as $key => $value) {
    $array= explode(" ",$data[$key]);
   $array_result[] = $array[0];
}
$vals = array_count_values($array_result);

print_r($vals);

OUTPUT

Array
(
    [2014-06-01] => 9
    [2014-06-02] => 3
    [2014-06-03] => 5
    [2014-06-04] => 4
)

array_count_values() will return an array with the dates as keys and the number of times they appear in the array as values. But first, build an array of just the dates without time:

foreach($array as $value) {
    $dates[] = date('Y-m-d', strtotime($value));
}
$counts = array_count_values($dates);

Make another variable that holds your dates and a counter. Go over your dates in your initial array and add 1 to the counter in the other array.

Example:

$dateCounters = array();
foreach($initialArray as $date){
    $niceDate = date('Y-m-d', $date);
    if(in_array($dateCounters, $niceDate){
        $dateCounters[$niceDate] += 1;
    } else {
        $dateCounters[$niceDate] = 1;
    }
}

First, remove the times from the dates using array_map(). Then use array_count_values() to count the date occurrences.

$new_array = 
    array_map(function($x){return date('Y-m-d', strtotime($x));}, $array);

$date_count = array_count_values($new_array);

See demo

Based on user3350731 solution, but with substr() instead of explode().

<?php

$data = array (
    '0' => '2014-06-01 12:45:02',
    '1' => '2014-06-01 12:45:03',
    '2' => '2014-06-01 12:48:52',
    '3' => '2014-06-01 12:50:31',
    '4' => '2014-06-01 13:18:49',
    '10' => '2014-06-01 13:33:16',
    '11' => '2014-06-01 14:20:48',
    '12' => '2014-06-01 14:24:44',
    '13' => '2014-06-01 15:28:16',
    '14' => '2014-06-02 10:50:56',
    '15' => '2014-06-02 10:51:07',
    '16' => '2014-06-02 18:16:13',
    '17' => '2014-06-03 11:20:20',
    '18' => '2014-06-03 11:58:46',
    '19' => '2014-06-03 11:59:03',
    '20' => '2014-06-03 12:00:51',
    '21' => '2014-06-03 12:01:21',
    '22' => '2014-06-04 19:03:17',
    '23' => '2014-06-04 19:06:03',
    '24' => '2014-06-04 19:12:03',
    '25' => '2014-06-04 21:18:03',
);

foreach ($data as $key => $value) {
   $array_result[] = substr($value, 0, 10);
}

$vals = array_count_values($array_result);

print_r($vals);

Note: no calls to strtotime(), date() or array_map().