Home > Backend Development > PHP Tutorial > Simple sample code for php date function

Simple sample code for php date function

WBOY
Release: 2016-07-25 08:55:53
Original
1028 people have browsed it
  1. Small example of php date function - bbs.it-home.org
  2. < ;body>
  3. echo time();//Output the number of seconds (timestamp) from 0:00:00 on January 1, 1970 to the current time
  4. echo "
    ";
  5. echo mktime(23,56,59,12,20,1999);//Output the timestamp of the specified time (hour, minute, second, month, day, year)
  6. echo mktime(23,56,59,13,20,1999);// If the time exceeds, extrapolate downward
  7. echo "
    #------------strtotime function-----------------#
    ";
  8. echo strtotime("2009-10-12 20:20:29");//Convert the specified time and date into a timestamp, month, day and year connection
  9. //You can only use - or /, hours, minutes and seconds The connection can only be:
  10. echo strtotime("2009/10/12 20/20/29");//Unable to output

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

  12. print_r(getdate());//Returns the date array under the current timestamp , the default is the current timestamp
  13. $arrtime=getdate(strtotime("2009-10-12 20:20:29"));//Returns an array of the specified date and timestamp
  14. echo "
    ";
  15. echo $ arrtime["minutes"];
  16. echo "
    ";
  17. echo date("Y‖m‖d H‖i‖s A");//Enter the date format of the specified date and timestamp, the default is the current time Poke
  18. echo "
    ";
  19. echo date("Y year m month d day H hour i minute s second A",strtotime("2009-10-12 20:20:29"));
  20. ?> ;
Copy code



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