I'm confused. I'm using a Global: PHP field inside a view to tweak the output of the row based on the date value of a certain field.

print (strtotime((string)$row->field_date));

Doesn't seem to return anything.

print $row->field_date;

Returns "Tuesday, December 1, 2015"

print strtotime('Tuesday, December 1, 2015');

Returns 1448956800

I've tried converting the $row object to an array just for fun with get_object_vars($row) but that didn't work either.

In my case I expect that print (strtotime((string)$row->field_date)); returns the value (unix timestamp) 1448956800.

  • and the desired output is? – Adrian Cid Almaguer Dec 2 '15 at 15:08
  • I'd expect print (strtotime((string)$row->field_date)); to print a unix timestamp like 1448956800. That is what I desire. – jonathanbell Dec 2 '15 at 16:17

$row->field_date contains markup, not just the date/string value hence strtotime() won't/can't return a valid unix timestamp. To fix, try using strip_tags() around the returned value of $row->field_date like:


or use "Strip HTML tags" option checkbox under "Rewrite Results" in the "Configure field" dialog.

  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review – digital Dec 2 '15 at 17:09
  • @digital Have another look, this does appear to answer the question – Clive Dec 2 '15 at 17:34
  • I've added more detail. I did feel that I was clearly answering the question. – jonathanbell Dec 2 '15 at 17:36

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.