What to do if php strftime is garbled?

藏色散人
Release: 2023-03-10 12:12:02
Original
1601 people have browsed it

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);
Copy after login

The output is

Îå, 18 12Ô 2015 11ʱ19·Ö36Ãë +0800
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template