ubuntu - PHP: strftime ignoring setlocale when time is formatted -


i trying output date time value in current locale, while playing around , trying en_us locale example, seems still using 24 hours time format , not 5:13:17 pm.

for example code:

setlocale(lc_time, 'en_us'); echo strftime("%c"); echo strftime("%x %x %p"); 

outputs:

wed nov 12 17:23:17 2014 11/12/14 17:23:17 pm 

i thought may ubuntu server config issue, locale -a returns(amongst others):

en_ng.utf8 en_nz.utf8 en_ph.utf8 en_sg.utf8 en_us en_us.iso88591 en_us.utf8 

any ideas?

thanks


update

from command line on ubuntu 12.04lts server:

>date --date='2014-11-13 16:21:42' +%x  04:21:42 pm  >locale  lang=en_us.utf-8 language=en_us:en lc_ctype="en_us.utf-8" lc_numeric="en_us.utf-8" lc_time="en_us.utf-8" lc_collate="en_us.utf-8" lc_monetary="en_us.utf-8" lc_messages="en_us.utf-8" lc_paper="en_us.utf-8" lc_name="en_us.utf-8" lc_address="en_us.utf-8" lc_telephone="en_us.utf-8" lc_measurement="en_us.utf-8" lc_identification="en_us.utf-8" lc_all=en_us.utf-8  >sudo dpkg-reconfigure locales  generating locales...   de_at.utf-8... up-to-date   de_be.utf-8... up-to-date   de_ch.utf-8... up-to-date   de_de.utf-8... up-to-date   de_li.utf-8... up-to-date   de_lu.utf-8... up-to-date   en_ag.utf-8... up-to-date   en_au.utf-8... up-to-date   en_bw.utf-8... up-to-date   en_ca.utf-8... up-to-date   en_dk.utf-8... up-to-date   en_gb.utf-8... up-to-date   en_hk.utf-8... up-to-date   en_ie.utf-8... up-to-date   en_in.utf-8... up-to-date   en_ng.utf-8... up-to-date   en_nz.utf-8... up-to-date   en_ph.utf-8... up-to-date   en_sg.utf-8... up-to-date   en_us.iso-8859-1... up-to-date   en_us.utf-8... up-to-date   en_za.utf-8... up-to-date   en_zm.utf-8... up-to-date   en_zw.utf-8... up-to-date generation complete. 

guys turns out had restart apache(!), reason needed reload locale..

i needed append .utf8 calls, this

setlocale(lc_time, 'en_us.utf8'); 

thank , hope helps others in future


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -