0

The closest I have found to this is This Question which sounded perfect but didnt work for me.

I need to show a list of results in my view equal to or greater than todays date. In the past, on a value formatted as a date, I use "now" and it works a treat.

I have built a view using webform submission data from the latest webform release, which enters a date field as plain text into the database rather than timestamp. So i have the raw value 2014-05-08 from the database.

I can test it by entering the date into the filter value as "2014-05-08" and it works perfectly, but of course I need todays date to update automatically.

I have tried using token filter to use a current date token, for a custom date type I created ('Y-m-d'), but nothing happens.

I have also installed views-php module, which hides a row if value returns true, but the following test didn't work

$date = date('Y-m-d');  
if ($row>value_1 == $date) {
return TRUE;
}

Is there any way to use tokens in the Configure filter criterion: value field?

EDIT:

There was a bug in the views-php module that this patch fixes.

I used a Global:php field to convert my text to date, but my next hurdle is that you cant use an exposed filter to filter results from a global:php field.

$eventdate = strtotime($row->value_1);
echo date('Y-m-d', $eventdate);
1

I don't really understand the problem. When a date isn't a date anymore and you can use php you can just convert it back to a date.

You even almost use the correct function.

$submittedDate = $row>value_1;

$Cdate = date('Y-m-d');
$Sdate = date_format(date_create($submittedDate), 'Y-m-d');

if ($Sdate == $Cdate) {
    return TRUE;
}

Shouldn't that do the trick?

  • Yeah that looks ideal, but its having no effect on the results. I want to create an exposed filter for the field "event date" and show results for today and tomorrow, based on "now" and "now + 1 day". Is there anyway to convert the text into a date format, and then filter by that? That's the reason I thought printing the token in the value field might be a better way of doing it. – Collins May 11 '14 at 14:00
  • 1
    You pointed me in the right direction, there was a bug in the views-php module that was returning the node ID for every value, so no wonder it wasnt converting it to a date! That was driving me nuts! – Collins May 11 '14 at 14:42

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.