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