How to convert date into string in php: You can use the date() function to achieve this. The date() function can format the timestamp into a more readable date and time. The usage method is: [echo date("Y/m/d")].
The PHP date() function formats a timestamp into a more readable date and time.
(Recommended tutorial: php graphic tutorial)
Syntax:
string date(string $format[, int $timestamp])
Parameters:
format Required. Specifies the format of the timestamp.
#timestamp Optional. Specify timestamp. The default is the current date and time.
(Video tutorial recommendation: php video tutorial)
Code implementation:
<?php echo date("Y/m/d") . "<br>"; echo date("Y.m.d") . "<br>"; echo date("Y-m-d"); ?>
Running result:
2020/10/21 2020.10.21 2020-10-21
The above is the detailed content of How to convert date to string in php. For more information, please follow other related articles on the PHP Chinese website!