I have been having trouble trying to figure out how to set a range of dates for a given lineItem using the google ads php client library. Basically, what I want to do is make a line item to be available for a specified start date and an end date but no success. In their example they have this snippet:

$lineItem->setStartDateTimeType(StartDateTimeType::IMMEDIATELY); $lineItem->setEndDateTime(             AdManagerDateTimes::fromDateTime(                 new DateTime('+1 month', new DateTimeZone('America/New_York'))             )         ); 

They're setting a start date for the line item to IMMEDIATELY, and and end date to 1 month from the time of creation. I tried passing to AdManagerDateTimes::fromDateTimeString a valid ISO 8601 string and no luck (GAM spits an error). Tried creating a DateTime() instance and passing it to the code above, nothing. I'm not too experienced in php and maybe this is way easier than i think it is but I'm stuck.

Any tips please? Thank you

Tag:google-ads-api, php

Only one comment.

  1. Ricardo Pagano

    i don't know if you already solve this issue, but you can change in the new DateTime include the date you want

    $lineItem->setEndDateTime( AdManagerDateTimes::fromDateTime( new DateTime('2023-02-12') ) );

Add a new comment.