php - can't get date in german language

前端 未结 4 1936
再見小時候
再見小時候 2021-01-18 07:19

I try to display a date in German but it doesn\'t work. I\'m using PHP with XAMPP.

These are my approaches:

function get_Datetime_Now() {
setlocale (         


        
相关标签:
4条回答
  • 2021-01-18 07:42

    I just comment to thank Tim Bodeit, and if someone is looking to set the month in spanish, this is the code that worked to me:

    setlocale(LC_TIME, 'es_ES', 'esp_esp');
    
    0 讨论(0)
  • 2021-01-18 07:50

    You are probably using a windows machine which has different language codes in PHP than a Unix based one.

    Try:

    setlocale(LC_TIME, 'de_DE', 'deu_deu');
    

    This will first try to set it to 'de_DE' (Linux/Unix) and have the 'deu_deu' code as a fallback for windows (PHP Version >= 4.3).

    Example in the german PHP documentation

    0 讨论(0)
  • 2021-01-18 07:51

    You can try with :

    setlocale(LC_TIME, 'de_DE', 'de_DE.UTF-8');
    echo strftime("%A, %d. %B %Y");
    

    worked for me

    0 讨论(0)
  • 2021-01-18 07:54

    The locale parameters are others compared linux to windows

    See here:

    • http://msdn.microsoft.com/en-us/library/39cwe7zf(v=vs.90).aspx
    • http://msdn.microsoft.com/en-us/library/cdax410z%28v=vs.90%29.aspx

    Usually it's "DEU" or "GERMAN" under Win.

    0 讨论(0)
提交回复
热议问题