Common\Core\Model::getUTCTimestamp PHP Method

getUTCTimestamp() public static method

Get the UTC timestamp for a date/time object combination.
public static getUTCTimestamp ( SpoonFormDate $date, SpoonFormTime $time = null ) : integer
$date SpoonFormDate An instance of \SpoonFormDate.
$time SpoonFormTime An instance of \SpoonFormTime.
return integer
    public static function getUTCTimestamp(\SpoonFormDate $date, \SpoonFormTime $time = null)
    {
        // validate date/time object
        if (!$date->isValid() || $time !== null && !$time->isValid()) {
            throw new \Exception('You need to provide two objects that actually contain valid data.');
        }
        // init vars
        $year = gmdate('Y', $date->getTimestamp());
        $month = gmdate('m', $date->getTimestamp());
        $day = gmdate('j', $date->getTimestamp());
        if ($time !== null) {
            // define hour & minute
            list($hour, $minute) = explode(':', $time->getValue());
        } else {
            // user default time
            $hour = 0;
            $minute = 0;
        }
        // make and return timestamp
        return mktime($hour, $minute, 0, $month, $day, $year);
    }