繁体   English   中英

PHP日期格式给出错误的输出

[英]php date format giving wrong output

我正在尝试从我的PHP页面向XML RPC Web服务发送日期值。

以下是我正在使用的代码

$LicenseData->LicenseDate  = "2014.05.06 00:00:00";
if (strlen($LicenseData->LicenseDate) > 0) {

  $arDate = explode(".", $LicenseData->LicenseDate);
  $arDate[0] = intval($arDate[0]);
  $arDate[1] = intval($arDate[1]);
  $arDate[2] = intval($arDate[2]);

  //DebugMessage($arDate);
  $ts = mktime(0, 0, 0, $arDate[1], $arDate[0], $arDate[2]);

  $LicenseData->LicenseDate  = date('Ymd\TH:i:s', $ts);

}

我的问题是,当我使用var_dump($LicenseData->LicenseDate); 我得到一个不同的datetime值作为字符串'20111104T00:00:00'(length = 17)输出。 解决方案表示赞赏。 提前致谢...

您在mktime日复一日地混在一起。

应该:

$ts = mktime(0, 0, 0, $arDate[1], $arDate[2], $arDate[0]);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM