WordPress at Your Fingertips
function is not described

SimplePie_Parse_Date::date_w3cdtf() public WP 1.0

Parse a superset of W3C-DTF (allows hyphens and colons to be omitted, as well as allowing any of upper or lower case "T", horizontal tabs, or spaces to be used as the time separator (including more than one))

{} It's a method of the class: SimplePie_Parse_Date{}

No Hooks.

Return

Int. Timestamp

Usage

$SimplePie_Parse_Date = new SimplePie_Parse_Date();
$SimplePie_Parse_Date->date_w3cdtf( $date );
$date (required)
-

Code of SimplePie_Parse_Date::date_w3cdtf() WP 5.8.2

public function date_w3cdtf($date)
{
	static $pcre;
	if (!$pcre)
	{
		$year = '([0-9]{4})';
		$month = $day = $hour = $minute = $second = '([0-9]{2})';
		$decimal = '([0-9]*)';
		$zone = '(?:(Z)|([+\-])([0-9]{1,2}):?([0-9]{1,2}))';
		$pcre = '/^' . $year . '(?:-?' . $month . '(?:-?' . $day . '(?:[Tt\x09\x20]+' . $hour . '(?::?' . $minute . '(?::?' . $second . '(?:.' . $decimal . ')?)?)?' . $zone . ')?)?)?$/';
	}
	if (preg_match($pcre, $date, $match))
	{
		/*
		Capturing subpatterns:
		1: Year
		2: Month
		3: Day
		4: Hour
		5: Minute
		6: Second
		7: Decimal fraction of a second
		8: Zulu
		9: Timezone ±
		10: Timezone hours
		11: Timezone minutes
		*/

		// Fill in empty matches
		for ($i = count($match); $i <= 3; $i++)
		{
			$match[$i] = '1';
		}

		for ($i = count($match); $i <= 7; $i++)
		{
			$match[$i] = '0';
		}

		// Numeric timezone
		if (isset($match[9]) && $match[9] !== '')
		{
			$timezone = $match[10] * 3600;
			$timezone += $match[11] * 60;
			if ($match[9] === '-')
			{
				$timezone = 0 - $timezone;
			}
		}
		else
		{
			$timezone = 0;
		}

		// Convert the number of seconds to an integer, taking decimals into account
		$second = round((int)$match[6] + (int)$match[7] / (10 ** strlen($match[7])));

		return gmmktime($match[4], $match[5], $second, $match[2], $match[3], $match[1]) - $timezone;
	}

	return false;
}