Date SQL to Form
@param  DateTime
@return String
188018
public static function getDateSQLToForm($datetime)
    { 
        //YYYY-mm-dd
        $t = $this->splitDate($datetime, false);

        return $t['date'] . '/' . $t['month'] . '/' . $t['year'];
    }
441936
private static function buildDateTime($dateTime, $startOfDay = false, $endOfDay = false)
    {
        $dateTime = new Carbon($dateTime);

        if ($startOfDay) {
            $dateTime = $dateTime->startOfDay();
        }

        if ($endOfDay) {
            $dateTime = $dateTime->endOfDay();
        }

        return (string) $dateTime;
    }
1197758
public static java.sql.Time toSqlTime(String time) {
		java.util.Date newDate = toDate("1/1/1970", time);

		if (newDate != null)
			return new java.sql.Time(newDate.getTime());
		else
			return null;
	}
309294
public static String toStringWithMinutes( DateTime dateTime ) {
        String dtStr = dateTime.toString(withMinutesformatter);
        return dtStr;
    }
738162
public static function dateSQLToForm($date)
    {
        //if (!empty($date) && $date != "0000-00-00" && $date != "0000-00-00 00:00:00"){
        if ($this->isDateSQL($date)) {
            $arr = explode('-', $date);
            $thn = (int)$arr[0];
            $bln = (int)$arr[1];
            $tgl = (int)$arr[2];

            if ($thn > 2000 AND $bln <= 12 AND $bln >= 1 AND $tgl <= 31 AND $tgl >= 1) {
                if ($tgl < 10) $tgl = '0' . $tgl;
                if ($bln < 10) $bln = '0' . $bln;
                if ($thn < 10) $thn = '0' . $thn;

                return $tgl . '/' . $bln . '/' . $thn;
            }
        }

        return '';
    }
765149
public static function getStringValue($dateTime): string
    {
        // do not return anything if no value was specified
        if (!$dateTime) {
            return '';
        }

        // until a mixed type is supported for type-hints, check the value here
        if (!$dateTime instanceof \DateTime) {
            return (new \DateTime($dateTime))->format(static::DATE_FORMAT);
        }

        return $dateTime->format(static::DATE_FORMAT);
    }
1308154
static public function validate($datetime)
    {
      // Break into parts
      $parts = preg_split('/[T ]/', $datetime);
      
      return Date::validate($parts[0]) && Time::validate($parts[1]);
    }
1119910
public function buildDateTimeRawValue(\DateTime $dateTime = null) {
		if (null === $dateTime) return null;
		return DateUtils::formatDateTime($dateTime, MssqlDateTimeColumn::generateFormatBuildRawValue(
				MssqlDateTimeColumn::FORMAT_BUILD_TYPE_RAW_VALUE, true, true, self::COLUMN_TYPE_PRECISION, false));
	}
480422
public function getDatetimeObject($datetime = null)
    {
        if ($datetime instanceof DateTimeInterface) {
            return $datetime;
        }

        if (is_integer($datetime)) {
            $datetime = date('Y-m-d H:i:s', $datetime);
        }

        return new DateTime($datetime);
    }
526216
protected function formatDatetimeString($datetime, $format = null)
    {
        $format = $format ?: $this->format;

        if (!$datetime) {
            return null;
        }

        if ($datetime instanceof Carbon) {
            return $datetime->format($format);
        }

        return date($format, strtotime($datetime));
    }
734490
public function buildDateTimeRawValue(\DateTime $dateTime = null) {
		if (null === $dateTime) {
			return null;
		}
		
		return DateUtils::formatDateTime($dateTime, MysqlDateTimeColumn::FORMAT_DATE_TIME);
	}
1027116
function _format_date_time( $datetime, $parno=6 ) {
    if( !isset( $datetime['year'] )  &&
        !isset( $datetime['month'] ) &&
        !isset( $datetime['day'] )   &&
        !isset( $datetime['hour'] )  &&
        !isset( $datetime['min'] )   &&
        !isset( $datetime['sec'] ))
      return ;
    $output = null;
    $output = date('Ymd', mktime( 0, 0, 0
                                 , (integer) $datetime['month']
                                 , (integer) $datetime['day']
                                 , (integer) $datetime['year']));
    if( isset( $datetime['hour'] )  ||
        isset( $datetime['min'] )   ||
        isset( $datetime['sec'] )   ||
        isset( $datetime['tz'] )) {
      if( isset( $datetime['tz'] )  &&
         !isset( $datetime['hour'] ))
        $datetime['hour'] = '0';
      if( isset( $datetime['hour'] )  &&
         !isset( $datetime['min'] ))
        $datetime['min'] = '0';
      if( isset( $datetime['hour'] )  &&
          isset( $datetime['min'] )   &&
         !isset( $datetime['sec'] ))
        $datetime['sec'] = '0';
      foreach( $datetime as $dkey => $dvalue ) {
        if( 'tz' != $dkey )
          $datetime[$dkey] = (integer) $dvalue;
      }
      $output .= date('\THis', mktime( $datetime['hour']
                                      , $datetime['min']
                                      , $datetime['sec']
                                      , $datetime['month']
                                      , $datetime['day']
                                      , $datetime['year']));
      if( isset( $datetime['tz'] ) && ( '' < trim ( $datetime['tz'] ))) {
        $datetime['tz'] = trim( $datetime['tz'] );
        if( 'Z' == $datetime['tz'] )
          $output .= 'Z';
        $offset = 0;
        $offset = $this->_tz2offset( $datetime['tz'] );
        if( 0 != $offset ) {
          $output    = date('Ymd\THis\Z', mktime( $datetime['hour']
                                                 , $datetime['min']
                                                 , $datetime['sec'] + $offset
                                                 , $datetime['month']
                                                 , $datetime['day']
                                                 , $datetime['year']));
        }
      }
      elseif( 7 == $parno )
        $output .= 'Z';
    }
    return $output;
  }
1371094
public function findInvalid($datetime = null)
    {
        $datetime = (null === $datetime) ? new \DateTime() : $datetime;

        return $this->createQueryBuilder('u')
            ->where('u.valid < :datetime')
            ->setParameter(':datetime', $datetime)
            ->getQuery()
            ->getResult();
    }
553892
public function format(\DateTime $dateTime)
    {
        $formatted = preg_replace_callback($this->regExp, function ($matches) use ($dateTime) {
            return $this->formatReplace($matches[0], $dateTime);
        }, $this->pattern);

        return $formatted;
    }
905140
public static function dateTimeToTimeStamp($datetime)
    {
        $year   = substr($datetime,0,4);
        $month  = substr($datetime,5,2);
        $day    = substr($datetime,8,2);
        $hour   = substr($datetime,11,2);
        $minute = substr($datetime,14,2);
        $second = substr($datetime,17,2);

        date_default_timezone_set("Europe/Berlin");
        $string = mktime($hour, $minute, $second, $month, $day, $year);

        return $string;
    }
1041823
protected function toSql($date)
    {
        $tz = new DateTimeZone(JFactory::getApplication()->get('offset'));
        $date = new JDate($date);
        $date->setTimezone($tz);
        return $date->toSql(true);
    }
626832
function _date2timestamp( $datetime, $tz=null ) {
    $output = null;
    if( !isset( $datetime['hour'] )) $datetime['hour'] = '0';
    if( !isset( $datetime['min'] ))  $datetime['min']  = '0';
    if( !isset( $datetime['sec'] ))  $datetime['sec']  = '0';
    foreach( $datetime as $dkey => $dvalue ) {
      if( 'tz' != $dkey )
        $datetime[$dkey] = (integer) $dvalue;
    }
    if( $tz )
      $datetime['tz'] = $tz;
    $offset = 0;
    if( isset( $datetime['tz'] ) && ( '' < trim ( $datetime['tz'] )))
      $offset = $this->_tz2offset( $datetime['tz'] );
    $output          = mktime( $datetime['hour']
                             , $datetime['min']
                             , $datetime['sec'] + $offset
                             , $datetime['month']
                             , $datetime['day']
                             , $datetime['year'] );
    return $output;
  }