Home >Backend Development >PHP Problem >What to do if php strftime is garbled?

What to do if php strftime is garbled?

藏色散人
藏色散人Original
2021-06-08 09:29:321638browse

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.

What to do if php strftime is garbled?

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn