本文整理汇总了PHP中Timestamp::setDate方法的典型用法代码示例。如果您正苦于以下问题:PHP Timestamp::setDate方法的具体用法?PHP Timestamp::setDate怎么用?PHP Timestamp::setDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Timestamp
的用法示例。
在下文中一共展示了Timestamp::setDate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getBlogDate
/**
* @static
* returns a Timestamp object with the blog time difference already
* applied, if needed
*
* @param blog either a blog id or a BlogInfo object
* @param timestamp
* @return A Timestamp object with time difference applied, if needed
* @see BlogInfo
*/
function getBlogDate($blog, $timestamp = null)
{
// check whether time differences are dynamically or statically
// applied, because in case of the former, we don't have to do
// anything here!
$config =& Config::getConfig();
if ($config->getValue("time_difference_calculation") == TIME_DIFFERENCE_CALCULATION_DYNAMIC) {
return new Timestamp($timestamp);
}
//
// how's this for function overloading??
// I know it's quite hackish, but it's a bit of a pain that
// we need to define two different functions depending on whether
// we're getting an object or an integer!
//
if (is_object($blog)) {
$blogSettings = $blog->getSettings();
$timeDifference = $blogSettings->getValue("time_offset");
} else {
include_once PLOG_CLASS_PATH . "class/dao/blogs.class.php";
$blogs = new Blogs();
$blogInfo = $blogs->getBlogInfoById($blog);
if (!$blogInfo) {
$timeDifference = 0;
} else {
$blogSettings = $blogInfo->getSettings();
$timeDifference = $blogSettings->getValue("time_offset");
}
}
// generate the date with the correct time difference applied
$t = new Timestamp();
$t->setDate(Timestamp::getDateWithOffset($t->getDate(), $timeDifference), DATE_FORMAT_TIMESTAMP);
return $t;
}