How to convert unix timestamp to string in php

WBOY
Release: 2023-03-15 16:46:01
Original
2008 people have browsed it

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)".

How to convert unix timestamp to string in php

The operating environment of this article: Windows 10 system, PHP version 7.1, Dell G3 computer.

How to convert unix timestamp into a string in php

date() function formats the local date and time and returns the formatted date string.

The syntax is:

date(format,timestamp);
Copy after login

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");
?>
Copy after login

How to convert unix timestamp to string in php

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!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template