In PHP, you can use the date() function to convert the Unix timestamp into a string. The function of this function is to format the specified Unix timestamp. The return result is a formatted Unix time string. The syntax is "date (timestamp formatted format, timestamp)".
The operating environment of this article: Windows 10 system, PHP version 7.1, Dell G3 computer.
date() function formats the local date and time and returns the formatted date string.
The syntax is:
date(format,timestamp);
format required. Specifies the format of the output date string
timestamp is optional. Specifies an integer Unix timestamp. The default is the current local time (time()).
If successful, the formatted date string will be returned. If failed, an E_WARNING error will be reported and FALSE will be returned.
Examples are as follows:
<?php // 输出日 echo date("l") . "<br>"; // 输出日、日期、月、年、时间 AM 或 PM echo date("l jS \of F Y h:i:s A"); ?>
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to convert unix timestamp to string in php. For more information, please follow other related articles on the PHP Chinese website!