我正在安排并显示我未来的所有帖子。当到达发布日期时,我想在帖子标题后添加一些文本。实际上,这篇文章将在发布日期到期,因此我需要在标题后面加上[THIS POST IS EXPIRED]
.
当计划发布的帖子达到发布日期时,标题后缀为“Expired”
1 个回复
SO网友:Pete
我发现下面的代码符合我的要求except 时间不准确。它只能精确到一整天,所以如果我的帖子在早上到期,它在下午仍然显示为当前状态。
如何才能更准确地计算时间?
<?php if (strtotime($post->post_date) > strtotime(\'+1 minute\')): ?>
<p>current</p>
<?php elseif (strtotime($post->post_date) > strtotime(\'-999999999 days\')) : ?>
<p>expired</>
<?php else : ?>
<?php endif; ?>