【问题标题】:Add custom text to the end of .date将自定义文本添加到 .date 的末尾
【发布时间】:2013-12-30 11:42:23
【问题描述】:

我的网站中有一小段代码显示了上次修改 index.php 的时间, 它看起来像这样:

<?php
    $filename = 'index.php';
    if (file_exists($filename)) {
        echo "<p style=text-align:center'>$filename was last modified: " .date ("F d Y G:i P ",   filemtime($filename));
    }
php?>

目前显示为,index.php最后修改时间:2013年12月30日12:36 +01:00

但在 +01:00 结尾处,我想添加文本“GMT”,以便用户知道它是 +1 GMT。

正在努力研究如何在不破坏代码的情况下将其放入其中。

【问题讨论】:

  • 你以前用过php吗?还是自己试过?这有点明显......

标签: php date time format last-modified


【解决方案1】:
echo "<p style=text-align:center'>$filename was last modified: ".date ("F d Y G:i P ",   filemtime($filename))." GMT";

【讨论】:

  • 这行得通,但在末尾添加了“Europe / Paris”,我正在尝试专门获取“GMT”:/ 无论如何谢谢!
  • 所以即使您的时区不同,您也想显示 GMT?
【解决方案2】:

试试这个:

 echo "<p style=text-align:center'>$filename was last modified: " .date ("F d Y G:i P ",   filemtime($filename)." GMT");

【讨论】:

  • 嗯,这不起作用,但它也不会破坏:S
【解决方案3】:

echo "&lt;p style=text-align:center'&gt;$filename was last modified: " .date ("F d Y G:i P e ", filemtime($filename));

【讨论】:

  • 这行得通,但在末尾添加了“Europe / Paris”,我正在尝试专门获取“GMT”:/ 无论如何谢谢!
猜你喜欢
  • 1970-01-01
  • 2021-10-21
  • 2013-11-25
  • 1970-01-01
  • 1970-01-01
  • 2022-06-11
  • 2014-06-26
  • 2017-03-04
  • 1970-01-01
相关资源
最近更新 更多