Simple example code for the PHP date function

Source: Internet
Author: User
  1. A small example of a php date function-bbs.it-home.org
  2. echo time ();//output from January 1, 1970 0:0 0 seconds to the current time (timestamp)
  3. echo "
    ";
  4. echo Mktime (23,56,59,12,20,1999);//output timestamp of the specified time (hour, minute, month, day, or year)
  5. echo Mktime (23,56,59,13,20,1999);///Time exceeded, downward projection
  6. echo "
    #------------Strtotime Function-----------------#
    ";
  7. Echo strtotime ("2009-10-12 20:20:29");//Convert the specified time date to a timestamp, the connection of the month-day year
  8. Can only be used-or/, the time and seconds of the connection can only be:
  9. Echo strtotime ("2009/10/12 20/20/29");//Cannot output

  10. echo "
    #-------------getdate, date function---------------#
    ";

  11. Print_r (GETDATE ());//Returns an array of dates under the current timestamp, which defaults to the current timestamp
  12. $arrtime =getdate (Strtotime ("2009-10-12 20:20:29"));//Returns an array of specified date timestamps
  13. echo "
    ";
  14. Echo $arrtime ["Minutes"];
  15. echo "
    ";
  16. echo Date ("Y‖m‖d h‖i‖s A");//Enter the date format for the specified date time stamp, default to the current timestamp
  17. echo "
    ";
  18. echo Date ("Y year m D Day h i minute s seconds A", Strtotime ("2009-10-12 20:20:29"));
  19. ?>
Copy Code

  • 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.