本文整理汇总了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'));
}