Simple sample code for php date functions

Source: Internet
Author: User
Simple sample code for php date functions

  1. A small example of a php date function -bbs.it-home.org
  2. Echo time (); // The number of seconds (timestamp) from 00:00:00, January 1, January 1, 1970 to the current time)
  3. Echo"
    ";
  4. Echo mktime (,); // output the timestamp of the specified time (hour, minute, second, month, day, and year)
  5. Echo mktime (,); // The time exceeds the threshold and is estimated to be greater.
  6. Echo"
    # ------------ Strtotime function -----------------#
    ";
  7. Echo strtotime ("20:20:29"); // converts a specified time date to a timestamp, indicating a connection between a month, a day, and a year.
  8. // Only-or/can be used. the connection time and minute-second can only be:
  9. Echo strtotime ("2009/10/12 20/20/29"); // unable to output

  10. Echo"
    # ------------- Getdate and date functions ---------------#
    ";

  11. Print_r (getdate (); // returns the date array under the current timestamp. the default value is the current timestamp.
  12. $ Arrtime = getdate (strtotime ("2009-10-12 20:20:29"); // returns an array with the specified date and time stamp.
  13. Echo"
    ";
  14. Echo $ arrtime ["minutes"];
  15. Echo"
    ";
  16. Echo date ("Y" m "d H" I "s A"); // enter the date format of the specified date and time stamp. the default value is the current time stamp.
  17. Echo"
    ";
  18. Echo date ("Y, m, d, H, I minute, s second, A", strtotime ("20:20:29 "));
  19. ?>

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.