Jump to content

Change date by API issues


kreativmonkey
 Share

Recommended Posts

Hi,

i want to set a date field value by api but i have problems to do so. I think this should be work:

$page->of(false);
$page->expire_date = time();
$page->save();
$page->of(true);

but when i look into the field i get not the saved time. The output is always: 30 Nov, -0001 00:00  (timestamp: -62169987208).

when i echo the time directly after the $page->of(true); than i get the current time but avter reload and output the time bevor $page->of(false); i get the time above!

do you have any idea whats the problem?

Link to comment
Share on other sites

ok, i think i found the issue but now i got the same problem again and i don't know why!

i loop thorw pages and want to set the expire_date to a new timestamp

$changeDate = wire("pages")->find(....);
foreach($changeDate as $p){
  $p->of(false);
  // Add 60 days to the publish date and store it to expire_date
  $p->expire_date = strtotime('+60 days', $p->publish_date);
  $p->save();
  $p->of(true);
}

but the first page in the loop will always store the wrong time: 30 Nov, -0001 00:00  (timestamp: -62169987208).

edit: i echo the output directly after save and of(true) and it is correct, but when I open the page ore output the field after reload, the wrong time is saved.

It's always the first page, tested with different pages. I don't know what i make wrong!

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

×
×
  • Create New...