Add Days to WordPress get_the_date function

I need to add an expiry date to an xml feed for a jobs website in YYYYMMDD format.

The position needs to expire 60 days after the initial posting date, i’ve used the code below to return the date each job was posted.

Read More
// Job date
$date = $xml_document->createElement("date");
$date->appendChild($xml_document->createCDATASection( get_the_date('Ymd') ));
$job_element->appendChild($date);

How do I simply grab this date and add 60 days to it?

Thanks 🙂

Related posts

1 comment

  1. $date = $xml_document->createElement("date");
    $wpDate = get_the_date('Y-m-d');
    $wpDate = new DateTime($wpDate);
    $wpDate->add(new DateInterval('P60D')); // P60D means a period of 60 days
    $wpDate = $wpDate->format('Ymd');
    $date->appendChild($xml_document->createCDATASection( $wpDate ));
    $job_element->appendChild($date);
    

Comments are closed.