Takes a DB timestamp and converts it into a Date object

@param   string  value
@param   array  any options to be passed

@return  \Fuel\Core\Date
540374
public static function type_time_decode($var, array $settings)
	{
		if ($settings['data_type'] == 'time_mysql')
		{
			// deal with a 'nulled' date, which according to MySQL is a valid enough to store?
			if ($var == '0000-00-00 00:00:00')
			{
				if (array_key_exists('null', $settings) and $settings['null'] === false)
				{
					throw new InvalidContentType('Value '.$var.' is not a valid date and can not be converted to a Date object.');
				}
				return null;
			}

			return \Date::create_from_string($var, 'mysql');
		}

		return \Date::forge($var);
	}
203885
public static function date(string $value): ?JavascriptFunction
    {
        $timestamp = strtotime($value);

        // wrong date format
        if (!$timestamp) {
            return null;
        }

        return new JavascriptFunction('kendo.parseDate("' . date('Y-m-d H:i:s', $timestamp) . '")');
    }
108556
private function toDateTimeObject($value)
    {
        $datetime = null;
        
        switch (true) {
            case $value instanceof \DateTime:
                $datetime = new DateTime($value->format(\DateTime::RFC3339));
                break;
            case is_numeric($value):
                $datetime = new DateTime(sprintf('@%d', $value));
                break;
            case is_string($value):
                $datetime = new DateTime($value);
                break;
        }
        
        return $datetime;
    }
340187
public function setValue($value)
	{
		if(is_numeric($value))
			$value = (int) $value;
		if(is_string($value))
			$value = strtotime($value);
		$value = date('Y/m/d', $value);
		$value = parent::setValue($value);
		return $value;
	}
490700
public function filter($value) {
        if($value === null)
            return null;

        try {
            $sourceDT = new DateTime($value);
            $targetTZ = new DateTimeZone($this->options["timezone"] ? $this->options["timezone"] : date_default_timezone_get());
            $targetDT = $sourceDT;
            $targetDT->setTimeZone($targetTZ);

            return $targetDT->format($this->options["format"]);
        }
        catch(Exception $e) {
            return false;
        }
    }
295480
public function convertToDatabaseValue($value, AbstractPlatform $platform)
    {
        if ($value instanceof Date) {
            return $value->toDateTime()->format($platform->getDateFormatString());
        }
        return parent::convertToDatabaseValue($value, $platform);
    }
563405
protected function formatDate($value)
    {
        $format = null;
        if (isset($this->input) && $this->input->hasOption('date-fmt')) {
            $format = $this->input->getOption('date-fmt');
        }
        if ($format === null) {
            $format = $this->config->getWithDefault('application.date_format', 'c');
        }

        // Workaround for the ssl.expires_on date, which is currently a
        // timestamp in milliseconds.
        if (substr($value, -3) === '000' && strlen($value) === 13) {
            $value = substr($value, 0, 10);
        }

        $timestamp = is_numeric($value) ? $value : strtotime($value);

        return $timestamp === false ? null : date($format, $timestamp);
    }
723450
protected function asDateTime($value)
    {
        // If this value is already a Carbon instance, we shall just return it as is.
        // This prevents us having to re-instantiate a Carbon instance when we know
        // it already is one, which wouldn't be fulfilled by the DateTime check.
        if ($value instanceof Carbon) {
            return Date::parse($value);
        }
        if ($value instanceof Date) {
            return $value;
        }
        // If the value is already a DateTime instance, we will just skip the rest of
        // these checks since they will be a waste of time, and hinder performance
        // when checking the field. We will just return the DateTime right away.
        if ($value instanceof DateTimeInterface) {
            return new Date(
                $value->format('Y-m-d H:i:s.u'), $value->getTimeZone()
            );
        }
        // If this value is an integer, we will assume it is a UNIX timestamp's value
        // and format a Carbon object from this timestamp. This allows flexibility
        // when defining your date fields as they might be UNIX timestamps here.
        if (is_numeric($value)) {
            return Date::createFromTimestamp($value);
        }
        // If the value is in simply year, month, day format, we will instantiate the
        // Carbon instances from that format. Again, this provides for simple date
        // fields on the database, while still supporting Carbonized conversion.
        if (preg_match('/^(\d{4})-(\d{1,2})-(\d{1,2})$/', $value)) {
            return Date::createFromFormat('Y-m-d', $value)->startOfDay();
        }
        // Finally, we will just assume this date is in the format used by default on
        // the database connection and use that format to create the Carbon object
        // that is returned back out to the developers after we convert it here.
        return Date::createFromFormat($this->getDateFormat(), $value);
    }
1366510
private function argValue($value) {
        if (is_bool($value)) {
            return (int)$value;
        } elseif ($value instanceof \DateTimeInterface) {
            return $value->format(self::MYSQL_DATE_FORMAT);
        } else {
            return $value;
        }
    }
194501
private function getLocalizedDate($value = null)
    {
        if ($value) {
            $value = $this->dateService
                ->toDateTime($value, 'app')
                ->format(Date::DB_FORMAT);
        }

        return $value;
    }
523749
public function castToDateTime($value)
    {
        if (is_int($value)) {
            $dt = new \DateTime();
            $dt->setTimestamp($value);
        } else {
            $dt = new \DateTime($value);
        }

        return $dt;
    }
671014
public function fromDateTime($value)
    {
        $format = $this->getDateFormat();

        $value = $this->asDateTime($value);

        return $value->format($format);
    }
204634
public function buildDateTime($value)
    {
        if ($value instanceof \DateTime) {
            return $value->format(static::DATE_TIME_FORMAT);
        } elseif (is_int($value)) {
            $date = new \DateTime();
            $date->setTimestamp($value);

            return $date->format(static::DATE_TIME_FORMAT);
        } elseif (is_string($value)) {
            $date = new \DateTime($value);

            return $date->format(static::DATE_TIME_FORMAT);
        }
        throw new \InvalidArgumentException('DateTime value should be int, string or \DateTime');
    }
209737
public function setTimezone($value)
    {
        /** @var static $date */
        $date = parent::setTimezone(static::safeCreateDateTimeZone($value));
        // https://bugs.php.net/bug.php?id=72338
        // just workaround on this bug
        $date->getTimestamp();

        return $date;
    }
503506
protected function interpretAsDate($value)
    {
        if (null === $value || 0 === $value || '' === $value) {
            return null;
        }

        if ($value instanceof DateTime) {
            return $value;
        }

        if (is_string($value)) {
            return new Carbon($value);
        }

        if (is_numeric($value)) {
            return Carbon::createFromTimestamp($value);
        }

        throw new UnexpectedValueException("Expecting null or date");
    }
1294796
protected function asDateTime($value)
    {
        // Legacy support for Laravel 5.0
        if (!$value instanceof Carbon) {
            return Carbon::instance($value);
        }

        return parent::asDateTime($value);
    }
1006391
public static function makeCarbon($value, $throwException = true)
    {
        if ($value instanceof Carbon) {
            // Do nothing
        }
        elseif ($value instanceof PhpDateTime) {
            $value = Carbon::instance($value);
        }
        elseif (is_numeric($value)) {
            $value = Carbon::createFromTimestamp($value);
        }
        elseif (preg_match('/^(\d{4})-(\d{2})-(\d{2})$/', $value)) {
            $value = Carbon::createFromFormat('Y-m-d', $value)->startOfDay();
        }
        else {
            try {
                $value = Carbon::parse($value);
            } catch (Exception $ex) {}
        }

        if (!$value instanceof Carbon && $throwException) {
            throw new InvalidArgumentException('Invalid date value supplied to DateTime helper.');
        }

        return $value;
    }