Home > Article > Backend Development > How to convert Chinese date string to time format in php
php method to convert Chinese date string to time format: 1. Create a php sample file; 2. Define a Chinese date string; 3. Implement it through the "date_parse_from_format()" and "mktime()" functions Just convert the date format.
The operating environment of this tutorial: Windows 10 system, PHP version 8.1, DELL G3 computer
How to convert Chinese date string to time format in php?
php processes the date containing Chinese year, month and day and converts it to a timestamp (for example, November 08, 2017 to a timestamp)
The result is
Array( [year] => 2017 [month] => 11 [day] => 8 [hour] => [minute] => [second] => [fraction] => [warning_count] => 0 [warnings] => Array ( ) [error_count] => 0 [errors] => Array ( ) [is_localtime] => )
2017 The corresponding timestamp for November 8th is: 1510070400
date_parse_from_format() function returns an associative array containing the specified date information according to the specified format.
date_parse_from_format(format,date);
mktime(hour,minute,second,month,day,year,is_dst);year is optional. Specified year.
The above is the detailed content of How to convert Chinese date string to time format in php. For more information, please follow other related articles on the PHP Chinese website!