0

I am sure that I am missing something very simple here, so I hope somebody can put me on the right track.

Use Case:

  1. I have a simple content type "Article"
  2. A date field of type: "Date and Time" is attached to this content type.
  3. Using any of "Rules" or "Business rules" module, I need when updating a node of type "Article", to set the value of the "date field" to be equal to the "date and time" of the node being updated.

What is the right token that must be used ?

So far:

I have been trying for days with no success, I have tried to use the below token but yet no sucess:

  • [node:changed:custom:D-M-Y-H:i:s]
  • [node:changed:custom:D-M-Y H:i:s]
  • [node:changed:custom:D/M/Y H:i:s]
  • [node:changed:custom:DMYHis]

Any help PLEASE!!

UPDATE #1:

The real use case:

I am using the "Field Timer" module in my project which provides field formatters for core module Datetime to display timer or countdown as a formatter.

So every time the node is updated, I want to set the "date field" to the current "date and time" of the node being updated (+) 20 minutes.

For Example if the current date & time of the node being updated is: 31/12/2018 15:00:00 so I want to set the "date & time" field value to: 31/12/2018 15:20:00

So the countdown formatter will start from 20 minutes and down until 0 minute.

Thank you,

1
  • Are you able to provide a time value in Rules then? If so and if it takes PHP formats you can just enter “now +20 minutes”.
    – Kevin
    Dec 31, 2018 at 14:19

1 Answer 1

1

Nodes already have a 'changed' property that would track this. Any reason why you don't want to use that? You can use {{ node.getChangedTime() }} in a Twig template for the raw value, or you can preprocess the node and take the changed value and format the date to your need into a new variable for the template. This way you don't need another field and Rules and reduce a lot of overhead.

1
  • I have a similar requirement and instead of opening a new question, maybe you could give a detailed example on how to add (+) let's say 30 minutes to a date field using a twig template as mentioned in you answer. Mar 13, 2019 at 6:26

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.