Jump to content

Set "created" by creating a page via API


Nico Knoll
 Share

Recommended Posts

I solved this with SQL:

First save normally and after this:

$sql = "UPDATE `pages` SET `created` = '".date('Y-m-d H:i:s', $data['crdate'])."', `modified` = '".date('Y-m-d H:i:s', $data['tstamp'])."' WHERE `name` = '".$page->name."';";

$update = wire('db')->query($sql);
Link to comment
Share on other sites

The $page->created and $page->modified properties are meant to be internal and consistent with actual page creation and modification dates in PW, so they aren't things that can be modified by the API. While you can go directly in and modify it with SQL, it's better to create your own properties using PW date fields. There's nothing that you can't do with your own fields that you can do with those internal created/modified fields. However, at present, I don't think it does any harm to modify them in SQL, but just saying that it's not a best practice.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...