php Method to convert unix timestamp to time: First create a PHP sample file; then use "date('Y-m-d H:i:s', 1547740800);" to convert the specified unix timestamp into time; finally output the conversion result through echo.
Recommended: "PHP Video Tutorial"
PHP Convert UNIX Timestamp UTC Time (TZ Format) Standard Time Methods to convert UNIX UTC GMT time and local time to each other
In PHP programming, we often encounter time in various formats
For example:
unix timestamp: 1547740800
UTC time: 2019-1-18T00:00:00Z
Standard time: 2019-1-18 00:00:00
The above three time formats all represent 0:00:00 on January 18, 2019. How to convert these three time formats in PHP? Here I will teach you
1. Convert UNIX to UTC
echo date('Y-m-dTH:i:sZ', 1547740800); //输出:2019-1-18T00:00:00Z
or
echo date('c',1547740800); //输出:2019-1-18T00:00:00Z+02:00
2. Convert UNIX to standard time
echo date('Y-m-d H:i:s', 1547740800); //输出:2019-1-18 00:00:00
3. Convert UTC Standard time
$utc='2019-1-18T00:00:00Z'; $unix= str_replace(array('T','Z'),' ',$utc); echo $unix; //输出:2019-1-18 00:00:00
4. Convert UTC to UNIX timestamp
$utc='2019-1-18T00:00:00Z'; $time= str_replace(array('T','Z'),' ',$utc); $unix=strtotime($time); echo $unix; //输出:1547740800
5. Convert standard time to UNIX timestamp
$time='2019-1-18 00:00:00'; $unix=strtotime($time); echo $unix; //输出:1547740800
6. Convert standard time to UTC time
$time='2019-1-18 00:00:00'; $unix=strtotime($time); $utc=date('Y-m-dTH:i:sZ', $unix); echo $utc; //输出:2019-1-18T00:00:00Z
The above is the detailed content of How to convert php unix timestamp to time. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Atom editor mac version download
The most popular open source editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SublimeText3 Mac version
God-level code editing software (SublimeText3)

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment
