Home >Backend Development >PHP Problem >What to do if php strftime is garbled?
php Solution to strftime garbled code: 1. Use GBK encoding to interpret the output; 2. Before calling strftime, set the system time to the desired encoding format.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
What should I do if php strftime is garbled?
PHP strftime() function output garbled code problem
Directly call strftime()
strftime(time_buf, 80, "%a, %e %b %G %T %z", p_stime);
The output is
Îå, 18 12Ô 2015 11ʱ19·Ö36Ãë +0800
Reason
strftime( ) is output according to the encoding format set by the system, which does not match the system.
Two solutions:
1. You need to set up a tool to display these texts and use GBK encoding to interpret the text. output.
2. Before calling strftime, set the system time to the desired encoding format, such as setlocale(LC_TIME, 'en_US.UTF-8')
Recommended learning: "PHP Video tutorial》
The above is the detailed content of What to do if php strftime is garbled?. For more information, please follow other related articles on the PHP Chinese website!