Php date to Chinese program code-PHP source code

Source: Internet
Author: User
The most used log is a digital date, but sometimes the job needs to convert the date into Chinese. How can this problem be solved? Let's take a look at the code for converting a php date to a Chinese character. The most used log is a digital date, but sometimes the job needs to convert the date into Chinese. How can this problem be solved? Let's take a look at the code for converting a php date to a Chinese character.

Script ec (2); script

If we use the date function to obtain the number displayed on the date

The Code is as follows:

Echo date ("Y-m-d ");
?>

Output

2014-10-11

If we want

October 11, 2014

What should I do? later I saw a friend write a sentence function.

The Code is as follows:

# Php date to Chinese
$ Str = '2017-10-11 ';
Echo str_replace (str_split ('000000'), str_split ('0, May 15, 0123456789, 3), date ('y', strtotime ($ str )). 'Year '. trim (str_replace ('110', '10', implode ('10', str_split (date ('n', strtotime ($ str ))))), '0 '). 'month '. trim (str_replace ('110', '10', implode ('10', str_split (date ('D', strtotime ($ str ))))), '0 ')). 'day ';
?>

Output result:

October 11, 2014

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.