Home > Backend Development > PHP Tutorial > How to format UNIX time with PHP date function date, dateunix_PHP tutorial

How to format UNIX time with PHP date function date, dateunix_PHP tutorial

WBOY
Release: 2016-07-13 10:02:05
Original
1036 people have browsed it

The method of PHP date function date formatting UNIX time, dateunix

This article describes the method of PHP date function date formatting UNIX time. Share it with everyone for your reference. The specific analysis is as follows:

The date function can format a unix time into the desired text output according to the specified format

The function syntax used is as follows

string date (string $Format);
string date (string $Format, int $Time);
Copy after login

The following is the demo code

<&#63;php
echo "When this page was loaded,\n";
echo 'It was then ', date ('r'), "\n";
echo 'The currend date was ', date ('F j, Y'), "\n";
echo 'The currend date was ', date ('M j, Y'), "\n";
echo 'The currend date was ', date ('m/d/y'), "\n";
echo 'The currend date was the ', date ('jS \o\f M, Y'), "\n";
echo 'The currend time was ', date ('g:i:s A T'), "\n";
echo 'The currend time was ', date ('H:i:s O'), "\n";
echo date ('Y');
date ('L')&#63;(print ' is'):(print ' is not');
echo " a leap year\n";
echo time ('U'), " seconds had elapsed since January 1, 1970.\n";
&#63;>
Copy after login

The output results are as follows

It was then Sat, 26 Dec 2009 07:09:51 +0000
The currend date was December 26, 2009
The currend date was Dec 26, 2009
The currend date was 12/26/09
The currend date was the 26th of Dec, 2009
The currend time was 7:09:51 AM GMT
The currend time was 07:09:51 +0000
2009 is not a leap year
1261811391 seconds had elapsed since January 1, 1970.
Copy after login

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/970865.htmlTechArticleHow to format UNIX time with PHP date function date, dateunix This article describes the PHP date function date formatting UNIX time with an example method. Share it with everyone for your reference. The specific analysis is as follows:...
Related labels:
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