Checks if give time string is indeed in the format specified.
Some leading zeros check might be omitted.
@param string $format
@param string $timeString
@return bool
439239
public static function validate($format, $timeString)
	{
		$time = DateTime::createFromFormat($format, $timeString);

		return ($time !== FALSE) && ($timeString === $time->format($format));
	}
569956
static public function validate($time)
    {
      // Check if date is a string
      if(is_string($time) && strlen(trim($time)) > 0)
        return false;
        
      // Check if date matches pattern
      if(!preg_match('/^' . self::PATTERN . '$/', $time, $matches))
        return false;
          
      // Extract values from time
      if(count($matches) == 5)
        list($original, $hours, $minutes, $seconds, $microtime) = $matches;
      else
        list($original, $hours, $minutes, $seconds) = $matches;
              
      // If microtime is set at it to seconds
      if(isset($microtime))
        $seconds += $microtime;
                
      // Check if all values are valid
      if(!self::validateTime($hours, $minutes, $seconds))
        return false;
                  
      return true;
    }
260473
public static function nice($dateString = null, $format = 'D, M jS Y, H:i') {

		$date = ($dateString == null) ? time() : strtotime($dateString);
		return date($format, $date);
	}
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);
    }
733176
protected function replaceDateTime($string, $timestamp)
    {
        foreach(static::DATE_FORMATS as $format)
        {
            $string = str_replace('{' . $format . '}', date($format, $timestamp), $string);
        }
        return $string;
    }
170565
protected function formatDateTime($format, $time = 'now', $timestamp = false)
    {
        if (empty($time)) {
            return;
        }

        if (false === $format) {
            return $time;
        } elseif (false !== strpos($format, '\\')) {
            return new $format($time);
        }

        if ($timestamp) {
            $dateTime = new DateTime();
            $dateTime->setTimestamp($time);
        } else {
            $dateTime = new DateTime($time);
        }

        return $dateTime->format($format);
    }
382545
public static function fromFormat(string $format, string $dateString) : DateTime
    {
        return new self(\DateTimeImmutable::createFromFormat('!' . $format, $dateString));
    }
891699
public static function isThisYear($time): bool
    {
        return (self::factory($time)->format('Y') === self::factory()->format('Y'));
    }
1177636
public static function formatTimestamp($timestamp, $format = self::DEFAULT_TIME_FORMAT, $timezone = self::DEFAULT_TIMEZONE)
    {
        $dateTime = new DateTime();
        $dateTime->setTimestamp($timestamp);
        $dateTime->setTimezone(new DateTimeZone($timezone));
        return $dateTime->format($format);
    }
372607
public static function formatDate($format, $timestamp)
    {
        static $datesPatterns = null;
        static $timesPatterns = null;

        if ($datesPatterns === null || $timesPatterns === null) {
            $datesPatterns = "/\b(" . implode('|', array_keys(static::$_map['date'])) . ")\b(?![^']*'(?:(?:[^']*'){2})*[^']*$)/i";
            $timesPatterns = "/\b(" . implode('|', array_keys(static::$_map['time'])) . ")\b(?![^']*'(?:(?:[^']*'){2})*[^']*$)/i";
        }

        // normalize formats
        $result = preg_replace_callback($datesPatterns, function ($matches) use ($timestamp) {
            return date(static::$_map['date'][$matches[1]], $timestamp);
        }, trim($format));

        $result = preg_replace_callback($timesPatterns, function ($matches) use ($timestamp) {
            return date(static::$_map['time'][$matches[1]], $timestamp);
        }, $result);

        return str_replace('\'', '', $result);
    }
33808
function( timeString, format ) {

			this.setFormat(format);
			this.clearTimeZone();
			var parts = [];

			if(timeString.toLowerCase() === 'z'){
				this.z = true;
				// set case for z
				this.autoProfile.tzZulu = (timeString === 'z')? 'z' : 'Z';
			}else{

				// discover timezone separtor for auto profile // default is ':'
				if(timeString.indexOf(':') === -1) {
					this.autoProfile.tzsep = '';
				}

				// finds timezone +HH:MM and +HHMM  ie +13:30 and +1330
				parts = timeString.match( /([\-\+]{1})?(\d\d)?:?(\d\d)?/ );
				if(parts[1]) {
					this.tzPN = parts[1];
				}
				if(parts[2]) {
					this.tzH = parts[2];
				}
				if(parts[3]) {
					this.tzM = parts[3];
				}


			}
			this.tzZulu = 'z';
			return this.toTimeString( this.format );
		}
1176748
protected function formatTime($timestamp = 0, $format = '')
    {
        switch ($this->timeset) {
            case 1:
                // swatch date
            return $this->swatchTime($timestamp);
            break;
            case 2:
                // iso date
            return $this->unixTimestampToISOtime($timestamp);
            break;
            default:
                // default time
            return date($this->dateFilter($format, $timestamp), $timestamp);
            break;
        }
    }
1310398
function (timeString, withDate) {
			if (!this.inst) {
				this.inst = $.datepicker._getInst(this.$input[0]);
			}

			if (withDate || !this._defaults.timeOnly) {
				var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat');
				try {
					var parseRes = parseDateTimeInternal(dp_dateFormat, this._defaults.timeFormat, timeString, $.datepicker._getFormatConfig(this.inst), this._defaults);
					if (!parseRes.timeObj) {
						return false;
					}
					$.extend(this, parseRes.timeObj);
				} catch (err) {
					$.timepicker.log("Error parsing the date/time string: " + err +
									"\ndate/time string = " + timeString +
									"\ntimeFormat = " + this._defaults.timeFormat +
									"\ndateFormat = " + dp_dateFormat);
					return false;
				}
				return true;
			} else {
				var timeObj = $.datepicker.parseTime(this._defaults.timeFormat, timeString, this._defaults);
				if (!timeObj) {
					return false;
				}
				$.extend(this, timeObj);
				return true;
			}
		}
909399
public static function fromFormat(string $format, string $string): TimeInterface
    {
        $digit = "[0-9]+";

        $regex = str_replace(["%s", "%m", "%h"], ["({$digit})", $digit, $digit], $format);
        preg_match("/{$regex}/", $string, $matches);
        $s = ($matches[1] ?? 0);

        $regex = str_replace(["%s", "%m", "%h"], [$digit, "({$digit})", $digit], $format);
        preg_match("/{$regex}/", $string, $matches);
        $m = ($matches[1] ?? 0);

        $regex = str_replace(["%s", "%m", "%h"], [$digit, $digit, "({$digit})"], $format);
        preg_match("/{$regex}/", $string, $matches);
        $h = ($matches[1] ?? 0);

        return new self(($h * 3600) + ($m * 60) + $s);
    }
647699
public static function isSupportedFormat($format)
    {
        if (!is_string($format)) {
            throw new Exception\InvalidArgumentException(__METHOD__ . " file_format must be a string");
        }
        return in_array((string) $format, self::$supportedFormats);
    }
681352
public static function DateFormat($format, $date = null)
  {
    if (!empty($date) && !is_int($date)) {
      $date = strtotime($date);
    }

    return strftime($format, $date ?: time());
  }
863329
public static function createFromFormat($format, $string, $timezone = null)
    {
        $timezone = $timezone ?: new DateTimeZone(date_default_timezone_get());
        $other = DateTime::createFromFormat($format, $string, $timezone);

        return (new static())->setTimestamp($other->getTimestamp())
                           ->setTimezone($other->getTimezone());
    }