I'm trying to set data value for a date field. The value is 7 days after a node was created. This works fine but I would like to have a fixed time of 6pm as the time value. Currently the time is set as the same time as the created node. How do I fix this?

2 Answers 2


The Drupal way was easier than I thought.

I changed it to direct input and used

now +7 days 18:00:00

and it's working.


You can do this very easy in PHP (ver. 5.3 and newer) by operating on the PHP DateTime object. Example:

$date = new DateTime();
$date->add(new DateInterval('P7D'));

The first line is the constructor, and sets the time to now without an argument (you can set it to another time by supplying an argument). The second advances it by 7 days. And the third forces the time to 6pm (18:00:00 in ISO 8601 syntax).

Then to see the result:

echo $date->format('Y-m-d H:i:s');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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