【问题标题】:change time format in table list更改表格列表中的时间格式
【发布时间】:2019-09-08 09:31:11
【问题描述】:

<thead> <th><b>Period Product</b></th> <thead>

还有这样的价值

<td><?= $recentlist->date_from; ?> - <?= $recentlist->date_to; ?></td>

现在结果是 2019-08-01 - 2019-08-31


我如何使用 javascript 将其更改为 2019/Aug/01 - 2019/Aug/31

对不起,我以前从来没有这样做过,如果你愿意帮助我,谢谢你

【问题讨论】:

  • 如果用 PHP 打印,为什么要用 JavaScript 格式化?使用strftime

标签: javascript php date


【解决方案1】:

TLDR;

使用php函数date_format

<td><?= date_format($recentlist->date_from, "Y-M-d"); ?> - <?= date_format($recentlist->date_to, "Y-M-d"); ?></td>

您需要使用名为date_format的东西

语法如下:

date_format( $date_object, $format );

在此处查看有关该功能的官方文档:

https://www.php.net/manual/en/function.date-format.php

对于所有可用的格式:

https://www.w3schools.com/php/func_date_date_format.asp

【讨论】:

  • 如果整个答案都是 TLDR,为什么还要发布它?
猜你喜欢
  • 1970-01-01
  • 2013-04-05
  • 1970-01-01
  • 2022-08-19
  • 1970-01-01
  • 1970-01-01
  • 2021-06-17
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多