The date function in PHP is followed by the time function

Source: Internet
Author: User
The date function and the time function in PHP.
The time () function is to get the current timestamp from January 1, 1970 Zero 0 minutes and 0 seconds

The date () function is a formatted timestamp. Does anyone know how he formatted it? Like if I had a time stamp, can I figure out the time myself? The time () timestamp gets the cumulative and of the seconds. But I tried to divide the time stamp by 60 equals points. Divided by 60 equals the hour divided by 24 How is it wrong?

------Solution--------------------
Landlord is said to get time stamp divided 24 hours a day to get days plus 1970 years

Gets the current time.

The question is 365 days a year or 366 days?

Just like getting the month is also, 28 days one months, 31 is also one months!
------Solution--------------------
That second count can only be counted to days. Because of the existence of leap years, it is not easy to draw.
------Solution--------------------
function ToDate ($time)//convert time to date
{
$arr =getdate ($time);
Echo $arr [year], "years", $arr [mon], "month", $arr [Mday], "Day", $arr [hours], "when", $arr [minutes], "min", $arr [seconds], "SEC";
}



Perfect solution
------Solution--------------------
PHP Code
function ToDate ($time)       
  • 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.