【问题标题】:Dividing date/time elements displayed from sql call, into sperate divs?将从sql调用显示的日期/时间元素划分为单独的div?
【发布时间】:2012-07-13 23:31:28
【问题描述】:

这个sql调用,

<div class="dateOnAd"><?php print $row['dttm_modified']; ?></div>

输出: 2012-05-22 15:07:28.

我需要想办法把输出分成不同的div

<div class="example-date">
   <span class="day">31</span> 
   <span class="month">July</span> 
   <span class="year">2009</span>
</div>

【问题讨论】:

  • 您是否有特殊原因不在查询中进行分隔?即,将日、月和年作为单独的字段返回。

标签: sql date time


【解决方案1】:
<div class="example-date">
    <span class="day"><?php echo date('d', $row['ddtm_modified']); ?></span>
    <span class="month"><?php echo date('F', $row['ddtm_modified']); ?></span>
    <span class="year"><?php echo date('Y', $row['ddtm_modified']); ?></span>
</div>

您可以在此处阅读有关 date() 函数的更多信息:date

【讨论】:

    猜你喜欢
    • 2018-08-28
    • 1970-01-01
    • 2018-01-14
    • 2018-02-10
    • 1970-01-01
    • 2016-06-06
    • 1970-01-01
    相关资源
    最近更新 更多