Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PayPal complete date format

Tags:

php

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 - $fullDays; // Set number of days
echo  $dayscalculate.(($dayscalculate == 1) ? " day" : " days");
?>  

Thank you

like image 575
user718359 Avatar asked Dec 16 '22 08:12

user718359


1 Answers

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()

like image 147
Michael Berkowski Avatar answered Jan 03 '23 17:01

Michael Berkowski