Translates available months inside a given string into their English representations taking into account the current language.

@param string $date

@return mixed|string
518807
public function translateMonthsToEnglish(string $date)
    {
        foreach ($this->getMonthTranslationMap() as $english => $translated) {
            if (false !== strpos($date, $translated)) {
                $date = str_replace($translated, $english, $date);
            }
        }

        foreach ($this->getShortMonthTranslationMap() as $english => $translated) {
            if (false !== strpos($date, $translated)) {
                $date = str_replace($translated, $english, $date);
            }
        }

        return $date;
    }
251906
public static function validDateForm($date)
    {
        $isOK = true;
        if (preg_match("/([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{2,4})/", $date)) {
            list($d, $m, $y) = explode("/", $date);
            $month = (int)$m;
            $day   = (int)$d;
            $year  = (int)$y;
            if (!checkdate($month, $day, $year)) {
                $isOK = false;
            }
        } else {
            $isOK = false;
        }
        if ($isOK == false) {
            $date = date('d/m/Y');
        }

        return $date;
    }
709889
protected function valueToDateTime($date)
    {
        if (!$date instanceof \DateTime) {
            $date = is_int($date) ? \DateTime::createFromFormat('U', $date) : new \DateTime((string)$date);
        }
        
        return $date;
    }
947818
public static function date2str($date, $format = '%d/%m/%Y')
    {
        $dt = new self();
        if (!$dt->set_date($date)) {
            return '';
        }
        
        return $dt->format($format);
    }
71780
function clMonthToMonth (clMonth) {
  assert.equal(typeof clMonth, 'string', `[senadores-asistencia]: No se puede convertir el mes ${clMonth}`)
  const months = {
    Enero: 0,
    Febrero: 1,
    Marzo: 2,
    Abril: 3,
    Mayo: 4,
    Junio: 5,
    Julio: 6,
    Agosto: 7,
    Septiembre: 8,
    Octubre: 9,
    Noviembre: 10,
    Diciembre: 11
  }
  assert.ok(months[clMonth] >= 0 && months[clMonth] < 12, `[senadores-asistencia]: No se puede convertir el mes ${clMonth}`)
  return months[clMonth]
}
563164
public static function toString($date, $pattern = "Y-m-d H:i")
    {
        if ($date && is_object($date) && ($date instanceof \MongoDate)) {
            return date($pattern, $date->sec);
        } elseif (is_int($date)) {
            return date($pattern, $date);
        }
    }
165611
public static function getNextMonth($date)
    {
        $arr = getdate();

        if ($arr['mon'] === 12) {
            $year = $arr['year'] + 1;
            $month = $arr['mon'] - 11;
            $day = $arr['mday'];

            $mday = $day < 10 ? '0' . $day : $day;

            $firstDay = $year . '-0' . $month . '-01';
            $lastDay = $year . '-0' . $month . '-' . $mday;
        } else {
            $time = strtotime($date);
            $firstDay = date('Y-m-01', strtotime(date('Y', $time) . '-' . (date('m', $time) + 1) . '-01'));
            $lastDay = date('Y-m-d', strtotime("$firstDay +1 month -1 day"));
        }

        return [$firstDay, $lastDay];
    }
593443
protected function _date($date = null) {
		if ($date === null || !$date instanceof \DateTimeInterface) {
			return '';
		}
		$datePieces = [];
		$datePieces[] = $date->format('Y');
		// JavaScript uses 0-indexed months, so we need to subtract 1 month from PHP's output
		$datePieces[] = (int)($date->format('m')) - 1;
		$datePieces[] = (int)$date->format('d');
		$datePieces[] = (int)$date->format('H');
		$datePieces[] = (int)$date->format('i');
		$datePieces[] = (int)$date->format('s');

		return 'new Date(' . implode(', ', $datePieces) . ')';
	}
39972
public static function getMonth($month, $langCode, $style = self::STYLE_LONG)
    {
        $langCode = static::checkLanguageCode($langCode);

        return self::$i18n[$langCode]['month'][$style][$month];
    }
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);
    }
948416
public static function getTheMonth($date)
    {
        $firstDay = date('Y-m-01', strtotime($date));
        $lastDay = date('Y-m-d', strtotime("$firstDay +1 month -1 day"));

        return array($firstDay, $lastDay);
    }
1057442
protected function normalizeDate($date)
    {
        $date = str_replace(array('/', '|'), '-', $date);

        if (empty($date)) {
            return date('Y-m-d H:i:s');
        } else if (ctype_digit($date)) {
            return date('Y-m-d H:i:s', $date);
        }

        return $date;
    }
1342484
public function toDateTime($date)
    {
        if ($date instanceof \DateTimeInterface) {
            return $date;
        }

        if (preg_match('/^(\d{4})-(\d{1,2})-(\d{1,2})$/', $date)) {
            return \DateTime::createFromFormat('Y-m-d', $date);
        }

        return \DateTime::createFromFormat($this->db->getQuery(true)->getDateFormat(), $date);
    }
685722
public function monthToString($month, $abbr=false)
  {
    switch($month){
      case 1:
        return $abbr ? $this->translate('MONTH_JANUARY_SHORT') : $this->translate('MONTH_JANUARY');
      case 2:
        return $abbr ? $this->translate('MONTH_FEBRUARY_SHORT') : $this->translate('MONTH_FEBRUARY');
      case 3:
        return $abbr ? $this->translate('MONTH_MARCH_SHORT') : $this->translate('MONTH_MARCH');
      case 4:
        return $abbr ? $this->translate('MONTH_APRIL_SHORT') : $this->translate('MONTH_APRIL');
      case 5:
        return $abbr ? $this->translate('MONTH_MAY_SHORT') : $this->translate('MONTH_MAY');
      case 6:
        return $abbr ? $this->translate('MONTH_JUNE_SHORT') : $this->translate('MONTH_JUNE');
      case 7:
        return $abbr ? $this->translate('MONTH_JULY_SHORT') : $this->translate('MONTH_JULY');
      case 8:
        return $abbr ? $this->translate('MONTH_AUGUST_SHORT') : $this->translate('MONTH_AUGUST');
      case 9:
        return $abbr ? $this->translate('MONTH_SEPTEMBER_SHORT') : $this->translate('MONTH_SEPTEMBER');
      case 10:
        return $abbr ? $this->translate('MONTH_OCTOBER_SHORT') : $this->translate('MONTH_OCTOBER');
      case 11:
        return $abbr ? $this->translate('MONTH_NOVEMBER_SHORT') : $this->translate('MONTH_NOVEMBER');
      case 12:
        return $abbr ? $this->translate('MONTH_DECEMBER_SHORT') : $this->translate('MONTH_DECEMBER');
    }
  }
798039
public function transform($date)
    {
        if (!$date instanceof DateTime) {
            $date = new DateTime($date);
        }

        $current = new DateTime('now');

        if ($this->isToday($date)) {
            return $this->trans('Today');
        }

        if ($this->isYesterday($date)) {
            return $this->trans('Yesterday');
        }

        if ($this->isTomorrow($date)) {
            return $this->trans('Tomorrow');
        }

        if ($this->isNextWeek($date)) {
            return $this->trans('Next %weekday%', [ '%weekday%' =>  $date->format('l') ]);
        }

        if ($this->isLastWeek($date)) {
            return $this->trans('Last %weekday%', [ '%weekday%' => $date->format('l') ]);
        }

        if ($this->isThisYear($date)) {
            return $date->format('F j');
        }

        return $date->format('F j, Y');
    }
125096
public static function localizeDate($string)
    {
        // Only translate dates in localized environments
        if (self::isLocalized()) {
            foreach (self::$_datetime_dictionary as $value) {
                $string = preg_replace('/\b' . $value . '\b/i', self::translate($value), $string);
            }
        }

        return $string;
    }
971102
protected function getFormatedDate($date)
    {
        if (! is_null($date)) {
            if (! ($date instanceof Carbon)) {
                $date = Carbon::parse($date);
            }

            $date = $date->timezone($this->getTimezone())->format($this->getFormat());
        }

        return $date;
    }