PayPal complete date format
PayPal send back the payment_date field in the following format 19:19:09 Sep 27, 2011
I am using php to calculate days remaining from payment_date, but my code is based on getting the format in 2011-09-27 12:19:00.
How do I change?
This is my code (which works perfectly if date in my correct format):
<?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 - $fullDa开发者_如何学Cys; // Set number of days
echo $dayscalculate.(($dayscalculate == 1) ? " day" : " days");
?>
Thank you
There should be no issue here. strtotime()
will accept PayPal's format as:
strtotime("19:19:09 Sep 27, 2011")
Just be sure you have the correct timezone set in your php.ini, or at runtime with date_default_timezone_set()
<?php
$end = date('Y-m-d H:i:s', strtotime("03:49:26 27 May 2013 PDT"));
echo $end;
?>
Result : 2013-05-27 11:49:26
精彩评论