gmmktime():你应该使用time()函数

时间:2017-01-11 18:36:30

标签: php

我有这段代码:

  $nowgmt = gmmktime();
  $monthstart = gmmktime(0, 0, 0, gmdate("n"), 1);
  if (gmdate("n") > 1) {
    $prevmonthstart = gmmktime(0, 0, 0, gmdate("n")-1, 1);
  }else{
    $prevmonthstart = gmmktime(0, 0, 0, 12, 1, gmdate("Y")-1);   
  }

问题是该网站回复:

  

严格标准:gmmktime():您应该使用time()函数   而是在第25行的*******处理最后一个月数组([更新]   => 1484159698 [lastmonth] =>数组([0] =>数组([姓氏] =>亨德森[名字] =>罗恩[cid] => 811669 [总] => 169750)[1]   =>数组([lastname] =>贝恩[名字] =>詹姆斯[cid] => 1311798 [总] => 127459)[2] =>数组([lastname] => Glottmann [firstname]   => Josh [cid] => 1275389 [总] => 123861)[3] =>数组([lastname] => Fitzgerald [firstname] => Sam [cid] => 1324927 [total] => 84313)[4] =>数组([lastname] => Gilson [名字] =>马修[cid] =>   1223952 [总] => 61687))[thismonth] =>数组([0] =>数组(   [lastname] => Fitzgerald [名字] => Sam [cid] => 1324927 [总计]   => 92129)[1] =>数组([lastname] => Glottmann [firstname] => Josh [cid] => 1275389 [total] => 55835)[2] =>数组([lastname] =>马托斯   [firstname] => Grant [cid] => 1318203 [总] => 43575)[3] =>排列   ([lastname] => Henderson [firstname] => Ron [cid] => 811669 [总计]   => 26379)[4] =>数组([lastname] => Masiel [firstname] => Jarid [cid] => 1373874 [total] => 25120)))数组([local] => 0   [访问] => 0)错误:在查询上个月的数据时,得到了   错误"查询错误:42S02,1146,表' ************'不存在"

1 个答案:

答案 0 :(得分:0)

gmmktime()的所有参数都默认为当前时间。如果省略所有参数,结果与调用time()相同,因为它返回当前时间戳。所以你应该使用

$nowgmt = time();