- Code: Select all
<cms:pages masterpage='your template title' >
try to replace 'your template title' wit the template your purchase_date is stored
<cms:pages masterpage='your template title' >
Tomarnst wrote:was an example so you get an error.
- Code: Select all
<cms:pages masterpage='your template title' >
try to replace 'your template title' wit the template your purchase_date is stored
<cms:pages masterpage=k_user_template page_id=k_user_id limit='5'>
<tr>
<th scope="row">
<cms:php>
global $CTX;
$today = new DateTime(date($CTX->get('cur_date')));
$pday = new DateTime(date($CTX->get('start_date')));
$dayz = $pday->diff($today)->days;
$CTX->set( 'dayz', $dayz, 'global' );
</cms:php>
</th>
<td><cms:show fullname /></td>
<td><cms:show address />, <cms:show postalcode /> <cms:show city /></td>
<td><cms:show phone /></td>
<td><cms:show account /></td>
<td><cms:show birthday /></td>
<td><cms:show varmearbeider /></td>
</tr>
</cms:pages>
Bartonsweb wrote: Try placing <cms:show dayz /> (and you should see this variable inside of a cms:dump placed within the pages loop.)
<cms:php>
global $CTX;
$today = new DateTime(date($CTX->get('cur_date')));
$pday = new DateTime(date($CTX->get('start_date')));
$dayz = $pday->diff($today)->days;
$CTX->set( 'dayz', $dayz, 'global' );
</cms:php>
AmaralSites wrote: I'm really sorry for replying to such an old post, however a doubt appeared, and I'm really not good at PHP.
The code works great, and gives me the difference between the dates. However, regardless if it's a date in future or past, It returns a positive number.
Ex.: If calculating the difference between today (09/02) and tomorrow (10/02), the result will be "1". However, if calculating the difference between today and yesterday, the result will still be "1", instead of "-1".
How can I solve this?