Completed
Push — master ( b4bd3a...383997 )
by Davide
03:45 queued 10s
created

formatDatePickerDateForMysql()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.8333
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
namespace DavideCasiraghi\LaravelEventsCalendar;
4
5
class LaravelEventsCalendar
6
{
7
    /***************************************************************************/
8
9
    /**
10
     * Format a date from datepicker (d/m/Y) to a format ready to be stored on DB (Y-m-d).
11
     * If the start date is null return today's date.
12
     *
13
     * @param  int  event id
14
     * @return \App\Event the active events collection
15
     */
16
    public static function formatDatePickerDateForMysql($DatePickerStartDate)
17
    {
18
        if ($DatePickerStartDate) {
19
            list($tid, $tim, $tiy) = explode('/', $DatePickerStartDate);
20
            $ret = "$tiy-$tim-$tid";
21
        } else {
22
            // If no start date selected the search start from today's date
23
            date_default_timezone_set('Europe/Rome');
24
            $ret = date('Y-m-d', time());
25
        }
26
27
        return $ret;
28
    }
29
    
30
    
31
32
33
}
34