Eunico Cornelius Posted March 6, 2018 Share Posted March 6, 2018 Hi, I am new to process wire and I've been trying to change the date time format in my webpage according to its language selection(example: English 'd/m/y' , Deutsch: 'd.m.y'). I know that using $datetime->getDateFormats(); we can achieve the type of formats in the shape of indexes. Also, by using $user->language->id we can know which language we are using. How do I combine this two functions so that when I select English/Deutsch, the date will be adjusted accordingly? Is there a specific function that can do this or is there any provided index in the $user->language somewhere. Thanks in advance :). Link to comment Share on other sites More sharing options...
dragan Posted March 6, 2018 Share Posted March 6, 2018 Which version are you running? If you go to Admin > Setup > Fields > yourDateField don't you see these options in the Details + Input Tabs? You can define date/time formats for each installed language. 1 Link to comment Share on other sites More sharing options...
Eunico Cornelius Posted March 6, 2018 Author Share Posted March 6, 2018 I am not using fields currently, is there any way to do this without fields or maybe code wise? Link to comment Share on other sites More sharing options...
mel47 Posted March 8, 2018 Share Posted March 8, 2018 Hi @Eunico Cornelius I use this way in my template: strftime('%A %e %b', $page->date->getUnformatted("date")) http://php.net/manual/en/function.strftime.php 2 Link to comment Share on other sites More sharing options...
Inxentas Posted April 5, 2018 Share Posted April 5, 2018 mel47'suggestion should work. Remember to put setlocale() in your config. A fresh PW installation should remind you of this. http://php.net/manual/en/function.setlocale.php You might be interested in making the <HTML> tags on your website obey the locale as well. https://www.w3.org/International/questions/qa-html-language-declarations 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now