本文整理汇总了PHP中DateHelper::format方法的典型用法代码示例。如果您正苦于以下问题:PHP DateHelper::format方法的具体用法?PHP DateHelper::format怎么用?PHP DateHelper::format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateHelper
的用法示例。
在下文中一共展示了DateHelper::format方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prettyFormat
static function prettyFormat($date, $format = '{day} {dd} {month} {yyyy}', $empty = 'indéfinie')
{
if (!($time = strtotime($date))) {
return $empty;
}
$after = strtotime("+7 day 00:00");
$afterTomorrow = strtotime("+2 day 00:00");
$tomorrow = strtotime("+1 day 00:00");
$today = strtotime("today 00:00");
$yesterday = strtotime("-1 day 00:00");
$beforeYesterday = strtotime("-2 day 00:00");
$before = strtotime("-7 day 00:00");
if ($time < $after && $time > $before) {
if ($time >= $after) {
$relative = strftime("%A", $date) . " prochain";
} else {
if ($time >= $afterTomorrow) {
$relative = "après demain";
} else {
if ($time >= $tomorrow) {
$relative = "demain";
} else {
if ($time >= $today) {
$relative = "aujourd'hui";
} else {
if ($time >= $yesterday) {
$relative = "hier";
} else {
if ($time >= $beforeYesterday) {
$relative = "avant hier";
} else {
if ($time >= $before) {
$relative = strftime("%A", $time) . " dernier";
}
}
}
}
}
}
}
if (preg_match('/[0-2][0-9]:[0-5][0-9]/', $date)) {
$relative .= ' à ' . date('H:i', $time);
}
} else {
$relative = 'le ' . DateHelper::format($format);
}
return $relative;
}
示例2:
echo ++$i % 2 ? 'odd' : 'even';
?>
">
<th scope="row">Type</th>
<td><?php
echo $Picture['type'];
?>
</td>
</tr>
<tr class="<?php
echo ++$i % 2 ? 'odd' : 'even';
?>
">
<th scope="row">Mise en ligne</th>
<td><?php
echo DateHelper::format($Picture['created_at']);
?>
</td>
</tr>
</tbody>
</table>
<ul class="actions">
<li><a class="sprite left prefix edit" title="Editer" href="<?php
echo UrlHelper::path(array('action' => 'edit'), $Picture['id']);
?>
">Editer</a></li>
<li><a class="sprite left prefix delete" title="Supprimer" href="<?php
echo UrlHelper::path(array('action' => 'delete'), $Picture['id']);
?>
">Supprimer</a></li>
示例3: ucfirst
?>
</a></strong><br>
<?php
echo $Picture['width'];
?>
x <?php
echo $Picture['height'];
?>
pixels<br>
<?php
echo ucfirst($Picture['type']);
?>
<br>
</td>
<td><?php
echo DateHelper::format($Picture['created_at'], '{dd} {month} {yy} à {HH}:{MM}');
?>
</td>
<td>
<ul class="actions">
<li><a class="sprite prefix edit insert" title="Insertion" href="<?php
echo UrlHelper::path(array('action' => 'insertionEdit'), $Picture['id']);
?>
">Insérer</a></li>
</ul>
</td>
</tr>
<? endforeach ?>
<? if (!count($Pictures)) : ?>
<tr class="empty <?php