Home > Backend Development > PHP Tutorial > The php date function formats and outputs the time in the specified range

The php date function formats and outputs the time in the specified range

WBOY
Release: 2016-07-25 08:55:36
Original
1217 people have browsed it
  1. /**
  2. * The date function formats and outputs the time in the specified range
  3. * by bbs.it-home.org
  4. */
  5. $stand = "2013-01-";
  6. for ($i = 1; $i $time = strtotime($stand . $i);
  7. $date[] = date("Ymd", $time);
  8. }
  9. print_r($date);
  10. ?>
Copy code

Achieve the effect: The php date function formats and outputs the time in the specified range attached, The date function gets the date of the previous or next day example:

  1. //Date definition
  2. $day = date("Ymd", strtotime("-1 day"));
  3. echo $day."n";
  4. $day = date( "Ymd", strtotime("+1 day"));
  5. echo $day."n";
Copy the code

The effect is as follows: The php date function formats and outputs the time in the specified range



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