calc field php syntax - an easy php problem

jcuming

Member
Hi. Can anyone help? for someone who knows php, this is probably a no-brainer. I don't.

I've a list with several fields. One of the fields is called 'assistant___Role' and is a date field.
Another field is called 'assistant___flag' and is a calc field.
I want the 'flag' field to be either null, or else to show the value of the 'Role' field.
I've put the code below in the calculation box for 'flag'. The code sort of works. But the output is in the format
Y-m-d h:s etc) I want it in the format 'd/m/y' (and no hours/seconds).


$thresholddate = strtotime("-36 Months");
$roledays = strtotime('{assistant___Role}');
$roledate = '{assistant___Role}';

if ($roledays < $thresholddate )
{ return date( $roledate) ; }

I would guess to get the format I want, I'd just change the line:

$roledate = '{assistant___Role}';
to
$roledate = date("d-m-Y",'{assistant___Role}');
But when I do, all output dates become 01-01-1970.
What am I doing wrong? I have no knowledge of php, so have just cobbled thi together from various websites.
THanks
James
 
Try ...

Code:
$roledate = date("d-m-Y", $roledays);

The date() function expects a UNIX timestamp, which you already have in $roledays (that's what strtotime() does). Your existing code is trying to feed an already formatted time string to date().

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top