Returns the time in seconds rounded down to the next whole day. E.g:
2015/12/11 12h:34m:23s becomes 2015/12/12 00h:00m:00s.

@param  int $time
@param $days int
@return int
487719
public static function getByNextDay($time, $days = 1)
    {
        return mktime(0, 0, 0, date("n", $time), date("j", $time) + $days, date("Y", $time));
    }
1106021
public static function subDays($date, $days)
    {
        $d = self::formatDate($date);
        $d = date_parse($d);
        $d = mktime($d['hour'], $d['minute'], $d['second'], $d['month'], $d['day'] - $days, $d['year']);
        return self::formatDate($d);
    }
978720
function DaysToNow(){ // as datetime object returns difference in seconds
		if(empty(self::$dtnow)){
			self::$dtnow=new \DateTime();
			}
		//Get difference
		$diff=$this->diff(self::$dtnow);
		$diff_days =$diff->format('%r').($diff->days);
		return $diff_days;
		}
631211
public static function time($seconds)
    {
        if ($seconds < 0) {
            return "n/a";
        }

        if ($seconds < 60) {
            return $seconds . " Seconds";
        }

        $minutes = floor($seconds / 60);
        $seconds = $seconds % 60;

        if ($minutes < 60) {
            if ($seconds >= 30) {
                $minutes++;
            }
            return $minutes . " Minutes";
        }

        $hours = floor($minutes / 60);
        $minutes = $minutes % 60;

        if ($hours < 24) {
            if ($minutes >= 30) {
                $hours++;
            }
            return $hours . " Hours";
        }

        $days = floor($hours / 24);
        $hours = $hours % 24;

        if ($hours >= 12) {
            $days++;
        }

        return $days . " Days";
    }
1040137
public static function roundTimestampToYear($timestamp)
    {
        $year  = date('Y', $timestamp);
        
        $roundedTimestamp = mktime(0, 0, 0, $month=1, $day=1, $year);
        
        return $roundedTimestamp;
    }
186387
protected function convertFromMinutes($minutes)
    {
        $seconds = $minutes * 60;

        $secondsInAMinute = 60;
        $secondsInAnHour  = 60 * $secondsInAMinute;
        $secondsInADay    = 24 * $secondsInAnHour;

        // extract days
        $days = floor($seconds / $secondsInADay);

        // extract hours
        $hourSeconds = $seconds % $secondsInADay;
        $hours       = floor($hourSeconds / $secondsInAnHour);

        // extract minutes
        $minuteSeconds = $hourSeconds % $secondsInAnHour;
        $minutes       = floor($minuteSeconds / $secondsInAMinute);

        // return the final string
        $output = '';

        if ($days > 0) {
            $output .= $days . ' ' . $this->pluralize('day', $days);
        }

        if ($hours > 0) {
            $output .= $hours . ' ' . $this->pluralize('hour', $hours);
        }

        $output .= $minutes . ' ' . $this->pluralize('minute', $minutes);

        return $output;
    }
787076
public static function formatStrTime($time, $withSeconds = true)
    {
        // Pad left with 0 in case we get numbers like 123, 12, 122015
        $time = str_pad($time.'', 6, '0', STR_PAD_LEFT);

        $_time = array();

        $_time[] = substr($time, 0, 2);
        $_time[] = substr($time, 2, 2);

        if ($withSeconds) {
            $_seconds = substr($time, 4, 2);
            $_time[] = $_seconds;
        }

        return implode(':', $_time);
    }
141066
public function subtractDays($days)
    {
        $days = (int) $days;
        $days = -$days;
        return $this->addDays($days);
    }
853081
protected function exceededTimeParser($time)
    {
        $tomorrow = Carbon::parse($time)->addMinutes(config('laravel2step.laravel2stepExceededCountdownMinutes'))->format('l, F jS Y h:i:sa');
        $remaining = $time->addMinutes(config('laravel2step.laravel2stepExceededCountdownMinutes'))->diffForHumans(null, true);

        $data = [
            'tomorrow'  => $tomorrow,
            'remaining' => $remaining,
        ];

        return collect($data);
    }
418369
private function getExpiresTime($time): int
    {
        if ($time instanceof \DateTimeInterface) {
            return (int) $time->format('U');
        }

        if (\is_numeric($time)) {
            // average year in seconds
            if ($time <= 31557600) {
                $time += \time();
            }

            return (int) $time;
        }

        return (int) (new \DateTime($time))->format('U');
    }
1304651
public static function toTimeString($time)
    {
        $times = array(
            'hour'   => 3600000,
            'minute' => 60000,
            'second' => 1000
        );

        $ms = $time;

        foreach ($times as $unit => $value) {
            if ($ms >= $value) {
                $time = floor($ms / $value * 100.0) / 100.0;
                return $time . ' ' . ($time == 1 ? $unit : $unit . 's');
            }
        }
        return $ms . ' ms';
    }
532309
public static function wasLastWeek($time) {
        $start = static::factory('last week 00:00:00');

        $end = clone $start;
        $end->modify('next week -1 second');

        $time = static::factory($time);

        return ($time >= $start && $time <= $end);
    }
44124
private function duration($time){
        if(is_numeric($time)){ 
            return $time;
        }//if
        return (new \DateTime($time))->getTimestamp() - (new \DateTime('now'))->getTimestamp();
    }
278371
public static function wasLastMonth($time) {
        $start = static::factory('first day of last month 00:00:00');

        $end = clone $start;
        $end->modify('next month -1 second');

        $time = static::factory($time);

        return ($time >= $start && $time <= $end);
    }
222439
protected function getCacheExpiresTime($time = null)
    {
        if ($time === self::EXPIRES_END_OF_DAY) {
            return class_exists(Carbon::class)
                ? round(Carbon::now()->secondsUntilEndOfDay() / 60)
                : $this->cacheMinutes;
        }

        return $time ?: $this->cacheMinutes;
    }
881611
protected function getFormatTime($time)
    {
        // Remaining times
        $hours = str_pad(floor($time / 60 / 60), 2, '0', STR_PAD_LEFT);
        $minutes = str_pad(floor(($time - ((int)$hours * 60 * 60)) / 60), 2, '0', STR_PAD_LEFT);
        $seconds = str_pad(floor(($time - ((int)$hours * 60 * 60) - ((int)$minutes * 60))), 2, '0', STR_PAD_LEFT);

        return "$hours:$minutes:$seconds";
    }
266114
public function setTimeFromTimeString($time)
    {
        $time = explode(':', $time);

        $hour = (int) $time[0];
        $minute = isset($time[1]) ? (int) $time[1] : 0;
        $second = isset($time[2]) ? (int) $time[2] : 0;

        return $this->setTime($hour, $minute, $second);
    }