Change date language

On WordPress, I created a custom meta field for input dates.

But I need return the dates in my current language. I try to use setlocale with no effect:

setlocale (LC_ALL, "de_DE");
$user_ID = get_current_user_id();
$date = strtotime( get_user_meta($user_ID, 'subscription', true)); // return 1434499200
$inscricao = date("F Y", $date); // return June 2015

Related posts

2 comments

  1. You might want to use strftime

    Format the time and/or date according to locale settings. Month and
    weekday names and other language-dependent strings respect the current
    locale set with setlocale().

    For example:

    $inscricao = strftime("%B %Y", $date);
    
  2. Found a solution:

    echo esc_html_e( date_i18n( 'F de Y'  , strtotime( get_user_meta($user_ID, 'subscription', true) ) ) );
    

Comments are closed.