Date not correct

Folks, another calc problem

I am trying to add 6 months to a date - I have a date element but the dates remain unchanged

PHP:
$day = substr( '{___tenancy_start_date}', 8, 2);
$month = substr('{___tenancy_start_date}', 5, 2);
$year = substr('{___tenancy_start_date}', 0, 4);
return date( 'd F Y', mktime(0, 0, 0, date( $month)+6, date( $day), date( $year)));

Can anyone point me to what is wrong?

Thanks as always
 
Look at the refrenece http://pl1.php.net/mktime
int mktime ([ int $hour = date("H") [, int $minute = date("i") [, int $second = date("s") [, int $month = date("n") [, int $day = date("j") [, int $year = date("Y") [, int $is_dst = -1 ]]]]]]] )

don`t use date($php_varible) just try single $php_varible without date() function
date('s') returns seconds for current timestamp

$day = substr( '{___tenancy_start_date}', 8, 2);
$month = substr('{___tenancy_start_date}', 5, 2);
$year = substr('{___tenancy_start_date}', 0, 4);
return date( 'd F Y', mktime(0, 0, 0, $month+6, $day, $year));

string date ( string $format [, int $timestamp = time() ] )
Probably you also should ParseInt for substring:
$int =(int)$string; $int = intval($string); $int = settype($string,'integer');
 
It's not really a 'calc' problem, it's a generic PHP date code handling problem.

I'd suggest first thing you do is var_dump() those values you are picking up from the placeholders, and make sure they are what you are expecting. You didn't say what element types they are.

-- hugh
 
Thanks guys

The date is is created using a date element


Sent via my iPhone using Tapatalk app so please excuse brevity and typing errors :)
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top