PayPal 以下列格式发回 payment_date 字段 19:19:09 Sep 27, 2011
我正在使用 php 来计算 payment_date 的剩余天数,但我的代码是基于在 2011-09-27 12:19:00 获取格式。
我该如何改变?
这是我的代码(如果日期格式正确,它可以完美运行):
<?php
$today = time();
$cdate = strtotime('2011-09-27');//strtotime($row_details['payment_date']);// testing
$dateDiff = $today - $cdate;
$fullDays = floor($dateDiff/(60*60*24));
$dayscalculate = 30 - $fullDays; // Set number of days
echo $dayscalculate.(($dayscalculate == 1) ? " day" : " days");
?>
谢谢
最佳答案
这里应该没有问题。 strtotime()
将接受 PayPal 的格式为:
strtotime("19:19:09 Sep 27, 2011")
只需确保在 php.ini 中设置了正确的时区,或者在运行时使用 date_default_timezone_set()
关于php - Paypal 完整日期格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7577779/