【问题标题】:php function for linux time conversionlinux时间转换的php函数
【发布时间】:2014-04-28 15:31:20
【问题描述】:

我是 PHP 新手,我需要一个 PHP 函数,它可以将 Linux 时间(如 1396310400)从 $variable 转换并返回人类可读的日期,如 1.apr。 2014 年! (不需要一天中的时间)?非常感谢任何建议。

【问题讨论】:

  • 我想指出的不是 LINUX 时间,而是 UNIX 时间,我相信 UNIX 时间是所有操作系统的基础时间。

标签: php linux function time


【解决方案1】:

echo date('d/m/Y', $time_linux);

阅读此处:http://php.net/manual/en/function.date.php,了解如何修改结果以准确显示您想要的内容。

【讨论】:

  • 我试图在一个函数中实现它,但我得到了一个错误! function overtagelsesdato($time_linux) { echo date('d/m/Y', $time_linux); } 返回 $time_linux;
  • 你为什么要返回 $time_linux? echo 已经打印好了。如果您希望将其返回,请将其插入变量并返回该变量。
  • 好的 - 我已经尝试过了,但它不起作用? function overtagelsesdato($time_linux) { echo date('d/m/Y', $time_linux); }
  • 我在 WP 中使用 xml 文件中的 linux 时间变量运行 wpallimport 插件,并且函数 'overtagelsesdato' 在导入运行后没有返回任何内容!?
【解决方案2】:

感谢您的意见。

这有效并在我的 wpallimport 运行中返回了一个人类可读的日期 - 起初我只是不理解语法:

function overtagelsesdato($time_linux) {

回显日期('d/m/Y', $time_linux); }

  • 谢谢 OfirH!

【讨论】:

    猜你喜欢
    • 2020-03-07
    • 2013-07-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-15
    • 2011-07-11
    • 1970-01-01
    • 2020-03-05
    相关资源
    最近更新 更多