traxwriter Posted June 12, 2014 Share Posted June 12, 2014 (edited) Hi All, I am looking to modify the due by date in email templates ($invoice_date_due). I want to subtract 1 day. I have tried doing this with php, however it doesn't look like you can put php into the email templates. (I just get a white screen (Even if i just put {php}{/php})) Bear in mind I don't want to update the due date of an invoice just chnage that date for use inside the email template. This is the code I have tried: {php} $ccdate = DateTime::createFromFormat('d/m/Y', $this->_tpl_vars["invoice_date_due"]); $ccdate->modify("plus 1 day"); $this->_tpl_vars["cc_date_due"] = $ccdate->format('d/m/Y'); {/php} Does anyone have any ideas? Thanks, Adam *More info: I need to be able to remove one day from the due date as we attempt to cature credit cards 1 day before due date. This is the line that would change: Payment will be taken automatically on {$invoice_date_due} from your credit card on record with us. So invoice due date might be 13/03/2015 and credit card charge date will be 12/03/2015 Edited June 13, 2014 by traxwriter More info 0 Quote Link to comment Share on other sites More sharing options...
jclarke Posted June 13, 2014 Share Posted June 13, 2014 This should do what you need: {$invoice_date_due|cat:'-1 day'|date_format:"%d/%m/%Y" } 0 Quote Link to comment Share on other sites More sharing options...
traxwriter Posted June 14, 2014 Author Share Posted June 14, 2014 This should do what you need: {$invoice_date_due|cat:'-1 day'|date_format:"%d/%m/%Y" } Thanks jclarke, This didn't quite work beucase strtotime doesn't work with slashes in the date format, however you helped me figure it out. Here's what worked: {$invoice_date_due|replace:"/":"-"|cat:" -1 day"|date_format:"%d/%m/%Y"} 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.