Welcome to the nuBuilder Forums!

Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.

Email templates

Questions related to using nuBuilder Forte.
Post Reply
Timo
Posts: 221
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: 4581
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 76 times
Been thanked: 536 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: 221
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