PHP Date Function date format the Unix time method _php tips

Source: Internet
Author: User
Tags echo date

This article describes the PHP date function Date format Unix time method. Share to everyone for your reference. The specific analysis is as follows:

A date function can format a UNIX time into the desired text output according to the specified format

Use to function syntax as follows

String Date (string $Format);
String Date (string $Format, int $Time);

Here is the demo code

<?php
echo "When this page is 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 is ', date (' G:i:s A T '), "\ n";
Echo ' The currend time is ', date (' H:i:s O '), "\ n";
echo Date (' Y ');
Date (' L ')? (print ' is '):(print ' isn't ');
echo "a leap year\n";
echo Time (' U '), "seconds had elapsed since January 1, 1970.\n";
? >

The output is as follows

It was then Sat, Dec 2009 07:09:51 +0000 the
currend date is December, 2009 the
currend date was Dec 26, 20
the Currend date was 12/26/09
the currend date is the 26th of Dec, 2009 the
currend time is 7:09:51 AM GM T
The currend time were 07:09:51 +0000
2009 is isn't a leap year 1261811391 seconds had elapsed since January
1 1970.

I hope this article will help you with your PHP program design.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.