This topic is locked

'View as' 'custom' problem

3/5/2008 8:37:28 AM
PHPRunner General questions
V
vytb author

Hi,
I want to appear a value using 'view as' 'custom' depending on the datediff of two other fields.
The code is

[codebox]global $data;

if

((strtotime($data["_st_course.DateEnd"])-strtotime($data["_st_course.DateStart"]))/(606024)>=100)

$value="positive";

else

$value="negative";[/codebox]
However the value is always 'else'=negative even when diff of dates is 150. What am I missing in this code?

J
Jane 3/5/2008

Vitas,
your code looks good.

To debug it print all values before:

global $data;

$str = $data["_st_course.DateEnd"]." = ".strtotime($data["_st_course.DateEnd"])."
";

$str.= $data["_st_course.DateStart"]." = ".strtotime($data["_st_course.DateStart"])."
";

$str.= "diff = ".(strtotime($data["_st_course.DateEnd"])-strtotime($data["_st_course.DateStart"]))/(606024);
if ((strtotime($data["_st_course.DateEnd"])-strtotime($data["_st_course.DateStart"]))/(606024)>=100)

$value="positive";

else

$value="negative";
$value.= "
".$str;