I tried to get the value of a date field that I use in a view, but the returned variable stays empty. Returning dates works for core date posted and date updated, but for me not for date fields added by the date module.

Comments

Hanno created an issue. See original summary.

hanno’s picture

Issue summary: View changes
hanno’s picture

Tested and when I create a custom global field and rewrite that to show the date as text, this text in this field is transfered to the rule. So this issue is related to deliver a date field.

hanno’s picture

Category: Bug report » Support request
Status: Active » Closed (works as designed)

It turns out it returns an array with the date field. I used php action to extract the date information.

dsweeney0126’s picture

Would you mind sharing the PHP action you used? Got the same issue here.

Much appreciated!

hanno’s picture

I added an 'Execute custom PHP code' action and in that action I added in Enter PHP code without <?php ?> delimiters.:

$author->field_work_period_start['und'][0]['value'] = $first_creation_date_start[0]['value'];
$author->field_work_period_start['und'][0]['value2'] = $first_creation_date_end[0]['value2'];

where author is an node-object with a date field 'field_work_period_start'. That node get saved at the end of the rule with a 'save entity' action. 'first_creation_date_start' and 'first_creation_date_end' are row variables delivered by the view (in my case using aggregation). As I needed to set the start and end date of the date field I used this. Note that I m not using time so not setting timezone.