Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Email templates

Questions related to using nuBuilder Forte.
Post Reply
Timo
Posts: 217
Joined: Thu Mar 15, 2018 9:26 pm
Has thanked: 1 time

Email templates

Unread post 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.
kev1n
nuBuilder Team
Posts: 4297
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Email templates

Unread post 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 );
Timo
Posts: 217
Joined: Thu Mar 15, 2018 9:26 pm
Has thanked: 1 time

Re: Email templates

Unread post by Timo »

Thanks Kevin, it worked like a charm!
Post Reply