Skip to content

Instantly share code, notes, and snippets.

@evgv
Last active February 8, 2017 13:29
Show Gist options
  • Save evgv/4f14c0532a2a97c54b8ebae9196d753a to your computer and use it in GitHub Desktop.
Save evgv/4f14c0532a2a97c54b8ebae9196d753a to your computer and use it in GitHub Desktop.
PHP. Setlocale.

Set ru locale for date

Use setlocale, strftime, strtotime, date and time.

Unix hosting

Meta with charset utf-8

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

Set ru locale and get date

    setlocale(LC_ALL, 'ru_RU.UTF-8');
    echo strftime("%d %B %Y", strtotime({MY DATE IN STRING})); // or strftime("%d %B %Y", time()) for current date

Windows hosting

Meta with charset windows-1251

  <meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />

Set ru locale and get date

  setlocale(LC_ALL, 'russian'); // "russian" instead "ru_RU.UTF-8"
  echo strftime("%d %B %Y", strtotime({MY DATE IN STRING})); // or strftime("%d %B %Y", time()) for current date
  
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment