Return a human friendly format of the date.

@param AnDate $date
@param array $config Optional array to pass format

@return string
968152
public function humanize($date, $config = array())
    {
        $config = new AnConfig($config);

        $config->append(array(
            'format' => '%B %d %Y',
            'relative' => false,
            'offset' => null,
        ));

        $format = $config->format;

        $diff = $this->_current_time->getDate(DATE_FORMAT_UNIXTIME) - $date->getDate(DATE_FORMAT_UNIXTIME);

        if ($config->relative) {
            $timeLeft = ($diff < 0) ? '-FUTURE' : '';

            $diff = abs($diff);

            if ($diff < 1) {
                return sprintf(AnTranslator::_('LIB-AN-DATE-MOMENT'), $diff);
            }

            if ($diff < 60) {
                return ($diff > 1) ? sprintf(AnTranslator::_('LIB-AN-DATE-SECONDS'.$timeLeft), $diff) : sprintf(AnTranslator::_('LIB-AN-DATE-SECOND'.$timeLeft), $diff);
            }

            $diff = round($diff / 60);

            if ($diff < 60) {
                return ($diff > 1) ? sprintf(AnTranslator::_('LIB-AN-DATE-MINUTES'.$timeLeft), $diff) : sprintf(AnTranslator::_('LIB-AN-DATE-MINUTE'.$timeLeft), $diff);
            }

            $diff = round($diff / 60);
            if ($diff < 24) {
                return ($diff > 1) ? sprintf(AnTranslator::_('LIB-AN-DATE-HOURS'.$timeLeft), $diff) : sprintf(AnTranslator::_('LIB-AN-DATE-HOUR'.$timeLeft), $diff);
            }

            $diff = round($diff / 24);
            if ($diff < 7) {
                return ($diff > 1) ? sprintf(AnTranslator::_('LIB-AN-DATE-DAYS'.$timeLeft), $diff) : sprintf(AnTranslator::_('LIB-AN-DATE-DAY'.$timeLeft), $diff);
            }

            $diff = round($diff / 7);

            if ($diff < 4) {
                return ($diff > 1) ? sprintf(AnTranslator::_('LIB-AN-DATE-WEEKS'.$timeLeft), $diff) : sprintf(AnTranslator::_('LIB-AN-DATE-WEEK'.$timeLeft), $diff);
            }
        } elseif ($config->offset) {
            $date->addHours($config->offset);
        }

        return $date->getDate($format);
    }
253880
public static function date2timestamp($date, $format = null)
    {
        $config = Grav::instance()['config'];
        $dateformat = $format ?: $config->get('system.pages.dateformat.default');

        // try to use DateTime and default format
        if ($dateformat) {
            $datetime = \DateTime::createFromFormat($dateformat, $date);
        } else {
            $datetime = new \DateTime($date);
        }

        // fallback to strtotime() if DateTime approach failed
        if ($datetime !== false) {
            return $datetime->getTimestamp();
        }

        return strtotime($date);
    }
1169297
public function date($date=null)
    {
        if(is_null($date)) {
            $date = $this->created_at;
        }
        return String::date($date);
    }
545502
public function formatDate($date)
    {
        // Get format
        $format = 'date_format';
        if ($this->get('time') === 'yes') {
            $format = 'datetime_format';
        }
        return DateTimeObj::format($date, DateTimeObj::getSetting($format));
    }
732615
public function setFieldFormatting(&$config)
    {
        $fieldFormatting = array();
        // Parse the column information
        foreach ($this->columns() as $source => $info) {
            if (isset($info['link']) && $info['link']) {
                $fieldFormatting[$source] = '<a href=\"$ObjectRecordLink\">$value</a>';
            }
            if (isset($info['text']) && $info['text']) {
                $fieldFormatting[$source] = $info['text'];
            }
        }
        return $fieldFormatting;
    }
254183
protected static function createDate(string $date, string $format = 'Y-m-d'): \DateTime
    {
        return \DateTime::createFromFormat($format, $date);
    }
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 '';
    }
717374
public function date($date, $format = null)
    {
        if ($this->isEmptyDate($date)) {
            return '';
        }

        $isLocalizerFormat = in_array($format, [Localizer::SHORT, Localizer::LONG, Localizer::VERBOSE]);

        if ($format && !$isLocalizerFormat) {
            return $this->toDateTime($date)->format($format);
        }

        if (!$this->localizer) {
            return $this->toDateTime($date)->format('Y-m-d');
        }

        return $this->localizer->date($date, $format ?: Localizer::SHORT);
    }
515601
public function formatTimeAgoForHumans($date, $html = true)
    {
        $value = Carbon::createFromTimeStamp(strtotime($date))->diffForHumans();
        return ($html) ? $this->decorate($value, $date) : $value;
    }
275698
public static function dateFormat($date, $time=false) 
	{
		if(is_numeric($date) && (int)$date == $date)
			$date = date('Y-m-d H:i:s', $date);
		
		$setting = OmmuSettings::model()->findByPk(1, array(
			'select' => 'site_dateformat, site_timeformat',
		));
		
		if($time == true) {
			$date = date($setting->site_dateformat, strtotime($date)).' '.date($setting->site_timeformat, strtotime($date)).' WIB';
		} else{
			$date = date($setting->site_dateformat, strtotime($date));
		}
		return $date;
	}
203428
public static function convertDate($date)
    {
        if (\is_int($date)) {
            $timestamp = $date;
        } else {
            $timestamp = \strtotime($date);
        }
        $string = \date('Y-m-d\TH:i:s\Z', $timestamp);

        return $string;
    }
696386
public function format($date, $format = 'iso8601', $validate = true)
    {
        $result = null;
        try {
            if ($validate) {
                $format = $this->validateFormat($format);
            }
            $result = $this->parse($date)->format($format);
        } catch (\Exception $e) {
        }

        return $result;
    }
824726
public static function dateSQL($date, $format = 'd-m-Y')
    {
        if (empty($date)) {
            return null;
        }

        $obj = DateTime::createFromFormat('Y-m-d H:i:s', $date);
        if (empty($obj)) {
            return null;
        }

        return $obj->format($format);
    }
642738
public static String getFormatDate(String format, Date date) {
        return getFormatDate(format, date, ZoneId.systemDefault().getId());
    }
1238100
protected function formatSeconds($pattern,$date)
	{
		$seconds=$date['seconds'];
		if($pattern==='s')
			return $seconds;
		elseif($pattern==='ss')
			return str_pad($seconds,2,'0',STR_PAD_LEFT);
		else
			throw new CException(Yii::t('yii','The pattern for seconds must be "s" or "ss".'));
	}
929128
public function dateFormat($date, $format = '%e %b %Y')
    {
        if ($date instanceof \DateTime) {
            $ts = $date->getTimestamp();
        } elseif (is_numeric($date)) {
            $ts = $date;
        } elseif (preg_match('/^[0-9]{4,4}-[0-9]{2,2}-[0-9]{2,2}T[0-9]{2,2}:[0-9]{2,2}.*/', $date)) {
            // timestamp format 2013-01-01T00:00:00
            $ts = new \DateTime($date);
            $ts = $ts->getTimestamp();
        } else {
            throw new \InvalidArgumentException(sprintf("Cannot format %s as a date", $date));
        }

        return strftime($format, $ts);
    }
722348
public function intlDateFormat($date)
    {
        if (($formatter = $this->getFormatter()) instanceof \IntlDateFormatter) {
            return $formatter->format($date);
        } elseif ($date instanceof \DateTime) {
            return $date->format('d-m-Y');
        }

        return date('d-m-Y', $date);
    }