Zend certified PHP/Magento developer

Assign product to category based by created_at products

I want to add product to my category (New Arrival) based from Created_At inside table `catalog_product_entity

class Index extends Action
{
    protected $_pageFactory;
    protected $_scopeConfig;
    protected $categoryLinkManagement;

    public function __construct(
        Context $context,
        PageFactory $pageFactory,
        ScopeConfigInterface $scopeConfig,
        CategoryLinkManagementInterface $categoryLinkManagement
    ) {
        $this->_pageFactory = $pageFactory;
        $this->categoryLinkManagement = $categoryLinkManagement;
        $this->_scopeConfig = $scopeConfig;
        return parent::__construct($context);
    }

    public function CreatedAt()
    {
        $date = $this->_scopeConfig->getValue('category_setting/general/day',ScopeInterface::SCOPE_STORE);
        $month = $this->_scopeConfig->getValue('category_setting/general/month',ScopeInterface::SCOPE_STORE);
        $year = $this->_scopeConfig->getValue('category_setting/general/year',ScopeInterface::SCOPE_STORE);
        
        return $year . $month . $date . ' 00:00:00';
    }

    public function execute()
    {
        $categoryId = 41;
        $category = Mage::getModel('catalog/category')->load($categoryId);
        $category->setPostedProducts(array()); // Removes all old products added to your category
        $category->save();
        
        $now = Mage::getModel('core/date')->timestamp(time());
        $dateEnd = date('Y-m-d' . ' 23:59:59', $now);

        $collection = Mage::getModel("catalog/product")->getCollection()->addAttributeToSelect("*")->addFieldToFilter('created_at', array(
            'from'     => CreatedAt(),
            'to'       => $dateEnd,
            'datetime' => true
        ));
        var_dump($collection);
        exit;
        foreach($collection as $product){
            $category = array_merge($category,$product->getCategoryIds());
            $product->setCategoryIds($category);
            $product->save();
        }
    }
}

but in the end when i try to check the value of $collection it returns me an error of this
enter image description here