Closed torvista closed 5 months ago
I'm confused, that's how that line reads currently. strtotime
returns an int
and the code section prior to that line has verified that the products_date_available
isn't null.
. 'T00:00:00' is appended to the strtotime result instead of being part of its parameter.
Wrong again, the 'T00:00:00' should be appended to the result of date.
It's the date()
function that's complaining that it's getting a string as its 2nd parameter.
That's because the int
from strtotime()
is getting the T00:00:00
string appended to it, making it a string.
Should the T00:00:00
be appended to the 'Y-m-d'
string instead? Or just to the end of the result of the call to date()
?
just to the end of the result of the call to date()
the T: is part of the GMC spec https://support.google.com/merchants/answer/6324470?hl=en#Format
From that spec:
If you don’t include a time, the start date will use 00:00:00, and the end date will use 23:59:59.
... which is probably reasonable in most cases.
Google is big on using standardized RFC formats for things. Is there already a compliant RFC date/time string format in PHP's supported formats? Why not use that instead of hacking things together manually?
Again, when a future date is set:
PHP Fatal error: Uncaught TypeError: date(): Argument #2 ($timestamp) must be of type ?int, bool given in ...\includes\classes\gpsfFeedGenerator.php:791 Stack trace:
0 ...\includes\classes\gpsfFeedGenerator.php(791): date('c', false
as the value passed to strtotime is eg: 2024-03-20 00:00:00 00:00:00
which returns false.
@torvista, next time, please open a new issue referencing a closed one; otherwise, I'm sure to miss the update!
https://github.com/lat9/gpsf/blob/5b23df84745fb3db16c7acf4b3cd9f340f7b3b45/includes/classes/gpsfFeedGenerator.php#L803 it seems this should be
$this->xmlWriter->writeElement('g:availability_date', date('Y-m-d', strtotime($product['products_date_available'] . 'T00:00:00')));