dmaxey Posted December 28, 2011 Share Posted December 28, 2011 I have a time and date using the code echo date("l jS \of F Y H:i:s."); Now I need to show this in several different languages, including French German and Dutch I have tried setlocale(); and echo strftime The date shows but still in English. Any idea how to show the day date and time in Php for the languages suggested. Quote Link to comment https://forums.phpfreaks.com/topic/253937-time-date-different-languages/ Share on other sites More sharing options...
SergeiSS Posted December 28, 2011 Share Posted December 28, 2011 In the help for date() function http://ru.php.net/manual/en/function.date.php it's written "To format dates in other languages, you should use the setlocale() and strftime() functions instead of date(). " Quote Link to comment https://forums.phpfreaks.com/topic/253937-time-date-different-languages/#findComment-1301831 Share on other sites More sharing options...
dmaxey Posted December 28, 2011 Author Share Posted December 28, 2011 Thanks for your reply. I have been there before and struggled to understand. I have tried this but just shows jS \of F Y H:i:s. instead of Woensdag 28 december 2011 13:49:28. <?php /* Set locale to Dutch */ setlocale(LC_ALL, 'nl_NL'); echo strftime("l jS \of F Y H:i:s."); ?> Will you give me further advice? Quote Link to comment https://forums.phpfreaks.com/topic/253937-time-date-different-languages/#findComment-1301836 Share on other sites More sharing options...
ignace Posted December 28, 2011 Share Posted December 28, 2011 Read the documentation? http://be2.php.net/strftime Quote Link to comment https://forums.phpfreaks.com/topic/253937-time-date-different-languages/#findComment-1301843 Share on other sites More sharing options...
dmaxey Posted December 28, 2011 Author Share Posted December 28, 2011 Right I have <?php setlocale(LC_Time, 'nld_nld'); $dutch= strftime("%A %d %B %Y - %H:%M",time()); echo $dutch; ?> which shows woensdag 28 december 2011 - 15:36 on my wamp server. When I put it online it shows Wednesday 28 December 2011 - 15:50 Where, exactly, am I going wrong Quote Link to comment https://forums.phpfreaks.com/topic/253937-time-date-different-languages/#findComment-1301868 Share on other sites More sharing options...
dmaxey Posted December 28, 2011 Author Share Posted December 28, 2011 Finally found a way to do this. My wamp server is obviously windows but my web host is Linux. So this goes before the head <?php date_default_timezone_set('Europe/madrid'); setlocale(LC_ALL, array('es.UTF-8','es_ES@euro','es_ES','spanish')); ?> and this goes in the body <?php $spanish= strftime("%A %d %B %Y - %H:%M",time()); echo $spanish; ?> Just change country identifiers for different ones. Quote Link to comment https://forums.phpfreaks.com/topic/253937-time-date-different-languages/#findComment-1301928 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.