Hi,
When I have an editable date fields on a couch page
and i like to show how long ago (in days) this date is. I think i have to get the Purchase date and subtract this from the current date..
Can this be done with couch sub tag ?
EDIT: subtracting with dates doesn't seem to work, I could however do this with:
When I have an editable date fields on a couch page
- Code: Select all
<cms:editable name='purchase_date' label='Purchase date' type='text'></cms:editable>
and i like to show how long ago (in days) this date is. I think i have to get the Purchase date and subtract this from the current date..
- Code: Select all
<cms:set days="<cms:date purchase_date format='Y-m-d H:i:s'/>" 'global'/>
<cms:set cur_date="<cms:date format='Y-m-d H:i:s'/>" 'global'/>
Can this be done with couch sub tag ?
EDIT: subtracting with dates doesn't seem to work, I could however do this with:
- Code: Select all
<cms:php>
global $CTX;
$today = new DateTime(date($CTX->get('cur_date')));
$pday = new DateTime(date($CTX->get('purchase_date')));
$dayz = $pday->diff($today)->days;
$CTX->set( 'dayz', $dayz, 'global' );
</cms:php>