Skip to content

How to format a date to Brazilian Portuguese #1286

Closed Answered by valentesolucoes
valentesolucoes asked this question in Q&A
Discussion options

You must be logged in to vote

Problem solved.
in plugin.php:

public function translateDate($date) {
        if (!$date) return;

        if (gettype($date) === 'string') $date = new Carbon($date);
        $fmt = datefmt_create(
            'pt_BR', // The output language.
            pattern: 'LLLL dd, Y' // The output formatting.
        );
        return ucfirst(datefmt_format($fmt, $date));
    }

in Frontend:
<span><i class="fa fa-calendar"></i> {{ record.published_up | translateDate }}</span>

Replies: 5 comments 13 replies

Comment options

You must be logged in to vote
1 reply
@valentesolucoes
Comment options

Comment options

You must be logged in to vote
5 replies
@valentesolucoes
Comment options

@mjauvin
Comment options

mjauvin Jan 15, 2025
Collaborator

@valentesolucoes
Comment options

@AIC-BV
Comment options

@mjauvin
Comment options

mjauvin Jan 15, 2025
Collaborator

Comment options

You must be logged in to vote
4 replies
@mjauvin
Comment options

mjauvin Jan 15, 2025
Collaborator

@AIC-BV
Comment options

@valentesolucoes
Comment options

@valentesolucoes
Comment options

Comment options

You must be logged in to vote
2 replies
@AIC-BV
Comment options

@AIC-BV
Comment options

Comment options

You must be logged in to vote
1 reply
@valentesolucoes
Comment options

Answer selected by valentesolucoes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants