【问题标题】:what is the output number of php strtotime(date("Y-m-d h:i:s")) indicates? [duplicate]php strtotime(date("Y-m-d h:i:s")) 的输出编号是多少? [复制]
【发布时间】:2018-05-29 09:22:44
【问题描述】:

我想在链接发送时间和链接激活时间之间找到15分钟的差异。为此,我如下,

<?php

$sentTime=strtotime(date("2018-05-29 06:11:42"));
$curTime=strtotime(date("Y-m-d h:i:s"));
$difference=$curTime-$sentTime;

echo $sentTime;
echo '<br>';
echo $curTime;
echo '<br>';
echo $difference;
?>

当我这样做时,它会给出一些数字, 那些数字表示什么? 如果是时间,是分钟还是秒还是毫秒?

有人可以帮助我吗?

【问题讨论】:

  • 为什么不检查函数定义?仅为此目的制作的php手册:-strtotime

标签: php


【解决方案1】:

函数strtotime() 返回一个时间戳,即自 1970 年 1 月 1 日 (UTC) 以来经过的秒数。

$sentTime$curTime$difference 是秒。

【讨论】:

    【解决方案2】:

    请这样使用,声明日期的正确方式

      $senttime= date("Y-m-d H:i:s",strtotime("2018-05-29 06:11:42"));
    

    【讨论】:

    • 投了反对票,因为它没有回答 OP 的问题,并且在没有解释的情况下给出代码在 SO 上是不受欢迎的,并且不会帮助任何人。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多