Programmatically change the page 'Created Date/Time' from a block

Hi, I’m looking to find a way to change the page created/date from within a custom page-list block. I’m basically wanting to check if a page attribute is yes/no and if it’s yes then set the page created date to a specific date (the page list is ordered by newest first, so if set to yes we would want it to move to the bottom of the page-list)

The following would change the public date of the current page to the current date/time. Hope this helps you in the right direction!!

$page = Page::getCurrentPage();
$date = date('Y-m-d H:i:s');
$page->update(array('cDatePublic' => $date)); // updates the posting date of the page to right now
1 Like