Dynamic Date in email

mike-gcs

Member
Is there a way to have the date dynamically change?
It would work like the FUTURE_DAYS_X tag.
My goal is to use this in an automated daily email.
 
There's the [DATE] tag which basically shows the current date... You also have a [CURRENT_*] set of tags for year, month, day.
Isn't this something you can use?
 
No. In my case, the email has a compliance part. One of the dates will always be 40 days in the future. The obvious way I can solve it is to create a field and put the export date + 40. Issue is that while the export may be today, the email may go out tomorrow.
 
You could register your own tag, to show a date when you need in future.
In the apps/ directory create a file called init-custom.php and place this in it:
PHP:
<?php
    
    // register the tag in available tags list
    hooks()->addFilter('campaign_template_available_tags_list', function(array $tags = []){
        $tags[] = ['tag' => '[FUTURE_DATE_40_DAYS]', 'required' => false];
    
        return $tags;
    });

    // and parse it
    hooks()->addFilter('campaigns_get_common_tags_search_replace', function(array $searchReplace = []) {
        $searchReplace['[FUTURE_DATE_40_DAYS]'] = date('Y-m-d', strtotime('+40 days'));
        
        return $searchReplace;
    });
 
Back
Top