本文整理汇总了PHP中Timestamp::getYearMonth方法的典型用法代码示例。如果您正苦于以下问题:PHP Timestamp::getYearMonth方法的具体用法?PHP Timestamp::getYearMonth怎么用?PHP Timestamp::getYearMonth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Timestamp
的用法示例。
在下文中一共展示了Timestamp::getYearMonth方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCalendar
function getCalendar($blogid, $period)
{
global $database;
$calendar = array('days' => array());
if ($period === true || !checkPeriod($period)) {
$period = Timestamp::getYearMonth();
}
$calendar['period'] = $period;
$calendar['year'] = substr($period, 0, 4);
$calendar['month'] = substr($period, 4, 2);
$visibility = doesHaveOwnership() ? '' : 'AND e.visibility > 0' . getPrivateCategoryExclusionQuery($blogid);
switch (POD::dbms()) {
case 'Cubrid':
$result = POD::queryAllWithDBCache("SELECT DISTINCT TO_CHAR(to_timestamp('09:00:00 AM 01/01/1970')+e.published, 'DD')\n\t\t\t\tFROM {$database['prefix']}Entries e\n\t\t\t\tWHERE e.blogid = {$blogid} AND e.draft = 0 {$visibility} AND e.category >= 0 AND\n\t\t\t\t\tTO_CHAR(to_timestamp('09:00:00 AM 01/01/1970')+e.published, 'YYYY') = '{$calendar['year']}' AND\n\t\t\t\t\tTO_CHAR(to_timestamp('09:00:00 AM 01/01/1970')+e.published, 'MM') = '{$calendar['month']}'", 'entry');
break;
case 'MySQL':
case 'MySQLi':
case 'PostgreSQL':
default:
$result = POD::queryAllWithDBCache("SELECT DISTINCT DAYOFMONTH(FROM_UNIXTIME(e.published)) \n\t\t\t\tFROM {$database['prefix']}Entries e\n\t\t\t\tWHERE e.blogid = {$blogid} AND e.draft = 0 {$visibility} AND e.category >= 0 AND YEAR(FROM_UNIXTIME(e.published)) = {$calendar['year']} AND MONTH(FROM_UNIXTIME(e.published)) = {$calendar['month']}", 'entry');
break;
}
if ($result) {
foreach ($result as $dayArray) {
list($day) = $dayArray;
array_push($calendar['days'], $day);
}
}
$calendar['days'] = array_flip($calendar['days']);
return $calendar;
}
示例2: getCalendar
function getCalendar($blogid, $period)
{
global $database;
$skinSetting = Setting::getSkinSettings($blogid);
$pool = DBModel::getInstance();
$pool->init("Entries");
$pool->setAlias("Entries", "e");
$pool->setQualifier("e.blogid", "eq", $blogid);
$pool->setQualifier("e.draft", "eq", 0);
$pool->setQualifier("e.category", ">=", 0);
if (!doesHaveOwnership()) {
$pool->setQualifier("e.visibility", ">", 0);
$pool = getPrivateCategoryExclusionQualifier($pool, $blogid);
}
$calendar = array('days' => array());
if ($period === true || !checkPeriod($period)) {
$period = Timestamp::getYearMonth();
}
$calendar['period'] = $period;
$calendar['year'] = substr($period, 0, 4);
$calendar['month'] = substr($period, 4, 2);
switch (POD::dbms()) {
case 'Cubrid':
$pool->setQualifier("TO_CHAR(to_timestamp('09:00:00 AM 01/01/1970')+e.published, 'YYYY')", "eq", $calendar['year'], true);
$pool->setQualifier("TO_CHAR(to_timestamp('09:00:00 AM 01/01/1970')+e.published, 'MM')", "eq", $calendar['month'], true);
$result = $pool->getAll("TO_CHAR(to_timestamp('09:00:00 AM 01/01/1970')+e.published, 'DD')", array('filter' => 'distinct', 'usedbcache' => true, 'cacheprefix' => 'entry'));
break;
case 'SQLite3':
$pool->setQualifier("strftime('%Y',e.published,'unixepoch')", "eq", $calendar['year'], true);
$pool->setQualifier("strftime('%m',e.published,'unixepoch')", "eq", $calendar['month'], true);
$result = $pool->getAll("strftime('%d',e.published,'unixepoch')", array('filter' => 'distinct', 'usedbcache' => true, 'cacheprefix' => 'entry'));
break;
case 'MySQL':
case 'MySQLi':
case 'PostgreSQL':
default:
$pool->setQualifier("YEAR(FROM_UNIXTIME(e.published))", "eq", $calendar['year'], true);
$pool->setQualifier("MONTH(FROM_UNIXTIME(e.published))", "eq", $calendar['month'], true);
$result = $pool->getAll("DAYOFMONTH(FROM_UNIXTIME(e.published))", array('filter' => 'distinct', 'usedbcache' => true, 'cacheprefix' => 'entry'));
break;
}
if ($result) {
foreach ($result as $dayArray) {
list($day) = $dayArray;
array_push($calendar['days'], $day);
}
}
$calendar['days'] = array_flip($calendar['days']);
return $calendar;
}
示例3: flushEntry
function flushEntry($entryId = null)
{
global $database;
if (empty($entryId)) {
$entryId = '';
} else {
$entryId = intval($entryId);
}
$Entries = POD::queryColumn("SELECT name\n\t\t\tFROM {$database['prefix']}PageCacheLog\n\t\t\tWHERE blogid = " . getBlogId() . "\n\t\t\tAND (name like 'entry-" . $entryId . "-%' OR name like '%RSS-" . $entryId . "' OR name like '%ATOM-" . $entryId . "')");
if (!empty($Entries)) {
CacheControl::purgeItems($Entries);
}
if (!empty($entryId)) {
$entry = POD::queryRow("SELECT userid, category, published FROM {$database['prefix']}Entries\n\t\t\t\tWHERE blogid = " . getBlogId() . " AND id = {$entryId}");
if (!empty($entry)) {
$entry['period'] = Timestamp::getYearMonth($entry['published']);
CacheControl::flushAuthor($entry['userid']);
CacheControl::flushCategory($entry['category']);
CacheControl::flushArchive($entry['period']);
CacheControl::flushDBCache('entry');
}
} else {
CacheControl::flushAuthor();
CacheControl::flushCategory();
CacheControl::flushDBCache('entry');
}
return true;
}
示例4: getEntryListWithPagingByPeriod
<?php
/// Copyright (c) 2004-2012, Needlworks / Tatter Network Foundation
/// All rights reserved. Licensed under the GPL.
/// See the GNU General Public License for more details. (/documents/LICENSE, /documents/COPYRIGHT)
require ROOT . '/library/preprocessor.php';
if (!empty($suri['id'])) {
$period = $suri['id'];
} else {
$period = Timestamp::getYearMonth();
}
fireEvent('OBStart');
require ROOT . '/interface/common/blog/begin.php';
if ($skinSetting['showListOnArchive'] != 0) {
$listWithPaging = getEntryListWithPagingByPeriod($blogid, $period, $suri['page'], $blog['entriesOnList']);
$list = array('title' => getPeriodLabel($period), 'items' => $listWithPaging[0], 'count' => $listWithPaging[1]['total']);
$paging = $listWithPaging[1];
if ($skinSetting['showListOnArchive'] == 1) {
$skinSetting['showListWithTotalEntries'] = true;
}
$listFeedURL = 'archive/' . $period;
require ROOT . '/interface/common/blog/list.php';
}
$entries = array();
if ($skinSetting['showListOnArchive'] != 2) {
list($entries, $paging) = getEntriesWithPagingByPeriod($blogid, $period, $suri['page'], $skinSetting['showListOnArchive'] == 3 ? $blog['entriesOnPage'] : $blog['entriesOnList']);
require ROOT . '/interface/common/blog/entries.php';
}
require ROOT . '/interface/common/blog/end.php';
fireEvent('OBEnd');
示例5: getCalendarView
function getCalendarView($period = null) {
global $service, $database, $db;
if ((empty($period) === true) || !TimePeriod::checkPeriod($period))
$period = Timestamp::getYearMonth();
$calendar = array('days' => array());
$calendar['period'] = $period;
$calendar['year'] = substr($period, 0, 4);
$calendar['month'] = substr($period, 4, 2);
if ($db->query("SELECT DISTINCT DAYOFMONTH(FROM_UNIXTIME(written)) FROM {$database['prefix']}FeedItems WHERE YEAR(FROM_UNIXTIME(written)) = {$calendar['year']} AND MONTH(FROM_UNIXTIME(written)) = {$calendar['month']}")) {
while (list($day) = $db->fetchArray())
array_push($calendar['days'], $day);
}
$calendar['days'] = array_flip($calendar['days']);
$current = $calendar['year'] . $calendar['month'];
$previous = TimePeriod::addPeriod($current, - 1);
$next = TimePeriod::addPeriod($current, 1);
$firstWeekday = date('w', mktime(0, 0, 0, $calendar['month'], 1, $calendar['year']));
$lastDay = date('t', mktime(0, 0, 0, $calendar['month'], 1, $calendar['year']));
$today = ($current == Timestamp::get('Ym') ? Timestamp::get('j') : null);
$currentMonthStr = Timestamp::format('%Y.%m', TimePeriod::getTimeFromPeriod($current));
define('CRLF', "\r\n");
ob_start();
?>
<table class="calendar" cellpadding="0" cellspacing="1" style="width: 100%; table-layout: fixed">
<caption class="cal_month">
<?php echo $currentMonthStr;?>
</caption>
<thead>
<tr>
<th class="cal_week2"><?php echo _t('일요일');?></th>
<th class="cal_week1"><?php echo _t('월요일');?></th>
<th class="cal_week1"><?php echo _t('화요일');?></th>
<th class="cal_week1"><?php echo _t('수요일');?></th>
<th class="cal_week1"><?php echo _t('목요일');?></th>
<th class="cal_week1"><?php echo _t('금요일');?></th>
<th class="cal_week1"><?php echo _t('토요일');?></th>
</tr>
</thead>
<tbody>
<?php
$day = 0;
$totalDays = $firstWeekday + $lastDay;
$lastWeek = ceil($totalDays / 7);
for ($week=0; $week<$lastWeek; $week++) {
// 주중에 현재 날짜가 포함되어 있으면 주를 현재 주 class(tt-current-week)를 부여한다.
if (($today + $firstWeekday) >= $week * 7 && ($today + $firstWeekday) < ($week + 1) * 7) {
echo ' <tr class="cal_week cal_current_week">'.CRLF;
} else {
echo ' <tr class="cal_week">'.CRLF;
}
for($weekday=0; $weekday<7; $weekday++) {
$day++;
$dayString = isset($calendar['days'][$day]) ? '<a class="cal_click" href="'.$service['path'].'/?archive='.$current.($day > 9 ? $day : "0$day").'">'.$day.'</a>' : $day;
// 일요일, 평일, 토요일별로 class를 부여한다.
switch ($weekday) {
case 0:
$className = " cal_day cal_day_sunday";
break;
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
$className = " cal_day";
break;
}
// 오늘에 현재 class(tt-current-day)를 부여한다.
$className .= $day == $today ? " cal_day4" : " cal_day3";
if ($week == 0) {
if ($weekday < $firstWeekday) {
$day--;
// 달의 첫째날이 되기 전의 빈 칸.
echo ' <td class="cal_day1"> </td>'.CRLF;
} else {
echo ' <td class="'.$className.'">'.$dayString.'</td>'.CRLF;
}
} else if ($week == ($lastWeek - 1)) {
if ($day <= $lastDay) {
echo ' <td class="'.$className.'">'.$dayString.'</td>'.CRLF;
} else {
// 달의 마지막날을 넘어간 날짜 빈 칸.
echo ' <td class="cal_day2"> </td>'.CRLF;
}
} else {
echo ' <td class="'.$className.'">'.$dayString.'</td>'.CRLF;
}
}
echo ' </tr>'.CRLF;
if ($day >= $lastDay) {
//.........这里部分代码省略.........