0

I am using the Computed Field module in D8. I am trying to compute some dates using the node created date as the start point.

As my first try, this code works:

$valuein = $entity->field_datefield->date;  
$valuewed = $valuein->modify('next wednesday');  
$value = $valuewed->format('D j.n.y');

but it refers to field_datefield, which is a custom field (for testing my code).

What I really want to do is calculate from the date the Node was created.
I tried loads of things including:

$valuein = $entity->created->date;  
$value = $valuein->format('D j.n.y');  

but I can't get anything to work.

Do you know the correct way of referring to the value in the created field?

  • Is $entity a node instance? – Victor F Jul 14 at 12:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.