src/Helpers/Time.php
public static function toUnix($original)
    {
        if (is_numeric($original)) {
            return $original;
        }

        // YYYY-MM-DD HH:MM:SS
        if (preg_match("/(?P<year>\d+)-(?P<month>\d+)-(?P<day>\d+) (?P<hour>\d+):(?P<minute>\d+):(?P<second>\d+)/", $original, $match)) {
            return mktime($match['hour'], $match['minute'], $match['second'], $match['month'], $match['day'], $match['year']);
        }
        // YYYY-MM-DD
        elseif (preg_match("/(?P<year>\d+)-(?P<month>\d+)-(?P<day>\d+)/", $original, $match)) {
            return mktime(0, 0, 0, $match['month'], $match['day'], $match['year']);
        }
        // Fail
        else {
            return strtotime($original);
        }
    }
public static function toUnix($original)
    {
        if (is_numeric($original)) {
            return $original;
        }

        // YYYY-MM-DD HH:MM:SS
        if (preg_match("/(?P<year>\d+)-(?P<month>\d+)-(?P<day>\d+) (?P<hour>\d+):(?P<minute>\d+):(?P<second>\d+)/", $original, $match)) {
            return mktime($match['hour'], $match['minute'], $match['second'], $match['month'], $match['day'], $match['year']);
        }
        // YYYY-MM-DD
        elseif (preg_match("/(?P<year>\d+)-(?P<month>\d+)-(?P<day>\d+)/", $original, $match)) {
            return mktime(0, 0, 0, $match['month'], $match['day'], $match['year']);
        }
        // Fail
        else {
            return strtotime($original);
        }
    }
public static function toUnix ( $ original ) { if ( is_numeric ( $ original ) ) { return $ original ; } // YYYY-MM-DD HH:MM:SS if ( preg_match ( "/(?P<year>\d+)-(?P<month>\d+)-(?P<day>\d+) (?P<hour>\d+):(?P<minute>\d+):(?P<second>\d+)/" , $ original , $ match ) ) { return mktime ( $ match [ 'hour' ] , $ match [ 'minute' ] , $ match [ 'second' ] , $ match [ 'month' ] , $ match [ 'day' ] , $ match [ 'year' ] ) ; } // YYYY-MM-DD elseif ( preg_match ( "/(?P<year>\d+)-(?P<month>\d+)-(?P<day>\d+)/" , $ original , $ match ) ) { return mktime ( 0 , 0 , 0 , $ match [ 'month' ] , $ match [ 'day' ] , $ match [ 'year' ] ) ; } // Fail else { return strtotime ( $ original ) ; } }
Converts a datetime timestamp into a unix timestamp.

@param datetime $original

@return mixed
Converts a datetime timestamp into a unix timestamp .