Page 1 of 1

Email templates

Posted: Thu Oct 27, 2022 5:34 pm
by Timo
I have tried the email templates. It makes sending emails a lot easier. Thanks a lot for your hard work.

One question: How can I format the date differently? It always appears in yyyy-mm-dd format. I want to format it as dd.mm.yyyy.

Re: Email templates

Posted: Sun Oct 30, 2022 8:23 am
by kev1n
Hi,

Replace the Hash Cookie with the formatted date value before it's replaced with nuReplaceHashVariables():

Code: Select all

function formatDate($date, $format) {

    if ($date == "") {
     return "";
    }

    $date = DateTime::createFromFormat('Y-m-d', $date);
    return $date->format($format);

}


$body = nl2br($template['body'];
$body  = str_replace( "#"."your_field"."#", formatDate("#your_field#", "d.m.Y"), $body );

Re: Email templates

Posted: Wed Nov 02, 2022 4:57 pm
by Timo
Thanks Kevin, it worked like a charm!