本文整理匯總了PHP中HabariDateTime::create方法的典型用法代碼示例。如果您正苦於以下問題:PHP HabariDateTime::create方法的具體用法?PHP HabariDateTime::create怎麽用?PHP HabariDateTime::create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類HabariDateTime
的用法示例。
在下文中一共展示了HabariDateTime::create方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: filter_blogroll_update_cron
/**
* Grabs update times from weblogs.com
* @todo use update time from weblogs.com instead of gmdate.
* @todo parse urls so we search for only '%host.domain.tld/path%' with no http://
*/
public function filter_blogroll_update_cron($success)
{
if (Options::get('blogroll__use_updated')) {
$request = new RemoteRequest('http://rpc.weblogs.com/changes.xml', 'GET');
$request->add_header(array('If-Modified-Since', Options::get('blogroll__last_update')));
try {
if ($request->execute()) {
try {
$xml = new \SimpleXMLElement($request->get_response_body());
} catch (\Exception $e) {
EventLog::log('Could not parse weblogs.com Changes XML file');
return false;
}
$atts = $xml->attributes();
$updated = strtotime((string) $atts['updated']);
foreach ($xml->weblog as $weblog) {
$atts = $weblog->attributes();
$match = array();
$match['url'] = (string) $atts['url'];
$match['feedurl'] = (string) $atts['rssUrl'];
$update = $updated - (int) $atts['when'];
// use LIKE for info matching
$posts = DB::get_results('SELECT * FROM {posts}
WHERE
{posts}.id IN (
SELECT post_id FROM {postinfo}
WHERE ( (name = ? AND value LIKE ? ) OR (name = ? AND value LIKE ? ) )
)
AND status = ? AND content_type = ?', array('url', "%{$match['url']}%", 'feedurl', "%{$match['feedurl']}%", Post::status('published'), Post::type(self::CONTENT_TYPE)), 'Post');
if ($posts instanceof Posts && $posts->count() > 0) {
foreach ($posts as $post) {
$post->updated = HabariDateTime::create($update);
$post->update();
EventLog::log("Updated {$post->title} last update time from weblogs.com");
}
}
}
Options::set('blogroll__last_update', gmdate('D, d M Y G:i:s e'));
return true;
} else {
EventLog::log('Could not connect to weblogs.com');
return false;
}
} catch (\Exception $e) {
EventLog::log('Could not connect to weblogs.com (request failed)', 'error', 'default', 'Blogroll', $e);
return false;
}
}
return $success;
}