本文整理匯總了PHP中WPSEO_Utils::is_valid_datetime方法的典型用法代碼示例。如果您正苦於以下問題:PHP WPSEO_Utils::is_valid_datetime方法的具體用法?PHP WPSEO_Utils::is_valid_datetime怎麽用?PHP WPSEO_Utils::is_valid_datetime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WPSEO_Utils
的用法示例。
在下文中一共展示了WPSEO_Utils::is_valid_datetime方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: get_datetime_with_timezone
/**
* Get the datetime object, in site's time zone, if the datetime string was valid
*
* @todo This is messed up, output type changed, doc wrong. Revert, add new method for formatted. R.
*
* @param string $datetime_string The datetime string in UTC time zone, that needs to be converted to a DateTime object.
* @param string $format Date format to use.
*
* @return DateTime|null in site's time zone
*/
public function get_datetime_with_timezone($datetime_string, $format = 'c')
{
static $utc_timezone, $local_timezone;
if (!isset($utc_timezone)) {
$utc_timezone = new DateTimeZone('UTC');
$local_timezone = new DateTimeZone($this->get_timezone_string());
}
if (!empty($datetime_string) && WPSEO_Utils::is_valid_datetime($datetime_string)) {
$datetime = new DateTime($datetime_string, $utc_timezone);
$datetime->setTimezone($local_timezone);
return $datetime->format($format);
}
return null;
}
示例2: get_datetime_with_timezone
/**
* Get the datetime object is the datetime string was valid with a timezone
*
* @param string $datetime The datetime string that needs to be converted to a Datetime object
*
* @return DateTime|string
*/
private function get_datetime_with_timezone($datetime)
{
if (!empty($datetime) && WPSEO_Utils::is_valid_datetime($datetime)) {
return new DateTime($datetime, new DateTimeZone($this->get_timezone_string()));
}
return null;
}
示例3: is_valid_datetime
/**
* Wrapper function to check if we have a valid datetime (Uses a new util in WPSEO)
*
* @param string $datetime
*
* @return bool
*/
private function is_valid_datetime($datetime)
{
if (method_exists('WPSEO_Utils', 'is_valid_datetime')) {
return WPSEO_Utils::is_valid_datetime($datetime);
}
return true;
}
示例4: test_is_valid_datetime_WITH_invalid_datetime
/**
* Test the datetime with an invalid date string
*
* @covers WPSEO_Utils::is_valid_datetime
*/
public function test_is_valid_datetime_WITH_invalid_datetime()
{
$this->assertFalse(WPSEO_Utils::is_valid_datetime('-0001-11-30T00:00:00+00:00'));
}