Format a php date format string to javascript compatible date format string
@param string $php_format The date format (e.g. "d.m.y H:i")
@return string The formatted js date string
322811
public static function formatPhpDateToJsDate($php_format)
    {
        $SYMBOLS_MATCHING = [
            // Day
            'd' => 'DD',
            'D' => 'D',
            'j' => 'd',
            'l' => 'DD',
            'N' => '',
            'S' => '',
            'w' => '',
            'z' => 'o',
            // Week
            'W' => '',
            // Month
            'F' => 'MM',
            'm' => 'MM',
            'M' => 'M',
            'n' => 'm',
            't' => '',
            // Year
            'L' => '',
            'o' => '',
            'Y' => 'YYYY',
            'y' => 'y',
            // Time
            'a' => '',
            'A' => '',
            'B' => '',
            'g' => '',
            'G' => '',
            'h' => '',
            'H' => 'HH',
            'i' => 'mm',
            's' => '',
            'u' => ''
        ];

        $replacement = "";
        $escaping    = false;

        for ($i = 0; $i < strlen($php_format); $i++) {
            $char = $php_format [$i];
            if ($char === '\\')            // PHP date format escaping character
            {
                $i++;
                if ($escaping) {
                    $replacement .= $php_format [$i];
                } else {
                    $replacement .= '\'' . $php_format [$i];
                }
                $escaping = true;
            } else {
                if ($escaping) {
                    $replacement .= "'";
                    $escaping    = false;
                }
                if (isset ($SYMBOLS_MATCHING [$char])) {
                    $replacement .= $SYMBOLS_MATCHING [$char];
                } else {
                    $replacement .= $char;
                }
            }
        }
        return $replacement;
    }
1222286
public function prettyDate($date, $format = null)
    {
        if (is_string($date)) {
            $date = new \DateTime($date);
        }

        if (null !== $format) {
            return $this->dateFormatter->prettyDate($date, $format);
        }

        return $this->dateFormatter->prettyDate($date);
    }
1126010
public function format_date( $options, $js = false ) {

		switch ( (string) pods_v( static::$type . '_type', $options, 'format', true ) ) {
			case 'wp':
				$format = get_option( 'date_format' );
				if ( $js ) {
					$format = $this->convert_format( $format, array( 'source' => 'php' ) );
				}
				break;
			case 'custom':
				if ( ! $js ) {
					$format = pods_v( static::$type . '_format_custom', $options, '' );
				} else {
					$format = pods_v( static::$type . '_format_custom_js', $options, '' );
					if ( empty( $format ) ) {
						$format = pods_v( static::$type . '_format_custom', $options, '' );
						$format = $this->convert_format( $format, array( 'source' => 'php' ) );
					}
				}
				break;
			default:
				$date_format = $this->get_date_formats( $js );
				$format      = $date_format[ pods_v( static::$type . '_format', $options, 'ymd_dash', true ) ];
				break;
		}//end switch

		return $format;
	}
333465
public function format($format = null) {
        if(is_null($format)) {
            $format = $this->getFormatter()->getDateTimeFormat();
        }
        return date($format, $this->getEpoch());
    }
340300
public static function format(
        float $timestamp = null,
        string $format = self::FORMAT
    ): string
    {
        if ($timestamp === null) {
            $timestamp = microtime(true);
        }

        $pos = strpos($format, "u");
        if ($pos !== false) {
            $escpos = $pos - 1;
            if ($escpos < 0 || $format{$escpos} !== "\\") {
                $ms = sprintf("%06d", ($timestamp - floor($timestamp)) * 1000000);
                $format = substr_replace($format, $ms, $pos, 1);
            }
        }

        return date($format, $timestamp);
    }
1025564
public static function formatDate($date, $format = 'Y-m-d')
    {
        if (!$date) {
            return null;
        }
        $date = new DateTime($date);
        return $date->format($format);
    }
7647
def dateFormat(when):
    
    retval = ""
    if when is not None:
        dow = dateformat.format(when, "l")
        dom = dateformat.format(when, "jS")
        month = dateformat.format(when, "F")
        if when.year != dt.date.today().year:
            retval = _("{weekday} {day} of {month} {year}")  \
                    .format(weekday=dow, day=dom, month=month, year=when.year)
        else:
            retval = _("{weekday} {day} of {month}")  \
                    .format(weekday=dow, day=dom, month=month)
    return retval
621584
public function formatForJson(): string
    {
        $date = $this->setTimezone(new \DateTimeZone('Etc/UTC'));
        $result = $date->format('Y-m-d\TH:i:s');
        $milliseconds = \floor($date->format('u') / 1000);

        if ($milliseconds > 0) {
            $result .= '.'.\str_pad((string) $milliseconds, 3, '0', \STR_PAD_LEFT);
        }

        return $result.'Z';
    }
243744
function dateFormat($field, $format, $alias = null) {
		$alias = $alias ? " AS " . $this->quoteIdentifier($alias, true) : '';

		return "DATE_FORMAT({$field}, '{$format}'){$alias}";
	}
657034
public static function timeFormat($timestamp = null, $format = 'Y-m-d H:i:s')
    {
        if ($timestamp === null) {
            $timestamp = time();
        } elseif (empty($timestamp)) {
            return null;
        } else {
            $timestamp = intval($timestamp);
        }
        if (strncmp($format, 'php:', 4) === 0) {
            $format = substr($format, 4);
        }
        
        return date($format, $timestamp);
    }
889734
@Nonnull
    @SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_BAD_PRACTICE")
    public String format(@Nonnull Date date) {
        SimpleDateFormat dateFormat = dateFormats.poll();
        if (dateFormat == null) {
            dateFormat = new SimpleDateFormat(pattern, locale);
            dateFormat.setTimeZone(timeZone);
        }
        try {
            return dateFormat.format(date);
        } finally {
            dateFormats.offer(dateFormat);
        }
    }
1071299
public function convertPhpToJavascriptFormat($phpFormat)
    {
        // Converts all the meaningful characters.
        $replacements = self::REPLACEMENTS;

        // Converts all the escaped meaningful characters.
        foreach (self::REPLACEMENTS as $from => $to) {
            $replacements['\\' . $from] = '[' . $from . ']';
        }

        return strtr($phpFormat, $replacements);
    }
323899
public function getDate($date = null, $format = 'Y-m-d H:i:s')
    {
        if (strlen($date) < 0) {
            $date = date('d-m-Y H:i:s');
        }

        $timeStamp = new DateTime($date);
        return $timeStamp->format($format);
    }
1160728
public static String formatDateAsYMD(Date date) {
        String retString = "";
        if (date != null) {
            retString = JinxUtils.ymdFormatter.format(date);
        }
        return retString;
    }
647006
public static function formatDate($varValue, $varFormat) {
        if (is_array($varValue)) {
            $temp = $varValue;
        } else {
            if (strtolower($varValue) == 'get' or strtolower($varValue) == 'post') {
                eval('$temp = &$_' . strtoupper($varValue) . ';');
            } else {
                $temp = array($varValue);
            }
        }
        foreach ($temp as $key => $value) {
            if (is_array($value)) {
                foreach ($value as $key2 => $value2) {
                    $datetime = null;
                    $date = null;
                    if (preg_match('/^([0-9]{4})[-,\/]([0-9]{1,2})[-,\/]([0-9]{1,2})/', $value2)) {
                        $datetime = explode(' ', $value2);
                        if (is_array($datetime) and count($datetime) > 1) {
                            $temp[$key][$key2] = date($varFormat, strtotime($datetime[0])) . ' ' . $datetime[1];
                        } else {
                            $temp[$key][$key2] = date($varFormat, strtotime($datetime[0]));
                        }
                    } elseif (preg_match('/^([0-9]{1,2})[-,\/]([0-9]{1,2})[-,\/]([0-9]{4})/', $value2, $date)) {
                        $datetime = explode(' ', $value2);
                        if (is_array($datetime) and count($datetime) > 1) {
                            $temp[$key][$key2] = date($varFormat, strtotime($date[3] . '-' . $date[2] . '-' . $date[1])) . ' ' . $datetime[1];
                        } else {
                            $temp[$key][$key2] = date($varFormat, strtotime($date[3] . '-' . $date[2] . '-' . $date[1]));
                        }
                    }
                }
            } else {
                $datetime = null;
                $date = null;
                if (preg_match('/^([0-9]{4})[-,\/]([0-9]{1,2})[-,\/]([0-9]{1,2})/', $value)) {
                    $datetime = explode(' ', $value);
                    if (is_array($datetime) and count($datetime) > 1) {
                        $temp[$key] = date($varFormat, strtotime($datetime[0])) . ' ' . $datetime[1];
                    } else {
                        $temp[$key] = date($varFormat, strtotime($datetime[0]));
                    }
                } elseif (preg_match('/^([0-9]{1,2})[-,\/]([0-9]{1,2})[-,\/]([0-9]{4})/', $value, $date)) {
                    $datetime = explode(' ', $value);


                    if (is_array($datetime) and count($datetime) > 1) {
                        $temp[$key] = date($varFormat, strtotime($date[3] . '-' . $date[2] . '-' . $date[1])) . ' ' . $datetime[1];
                    } else {
                        $temp[$key] = date($varFormat, strtotime($date[3] . '-' . $date[2] . '-' . $date[1]));
                    }
                }
            }
        }
        return $temp;
    }
1348867
protected function createDate($date_string) {
    // Split from delimiter.
    $timestamp = explode('|', $date_string);

    $date = strtotime($timestamp[0]);
    $date = date('Y-m-d', $date) . 'T' . $timestamp[1] . ':00';

    return strtotime($date);
  }
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);
    }