Hướng dẫn php loop last 30 days - vòng lặp php trong 30 ngày qua

Tôi cần viết một vòng lặp để xuất 30 ngày qua từ ngày hôm qua theo định dạng sau:

2014-02-02
2014-02-03
2014-02-04
...
2014-03-04

Tôi nghĩ rằng tôi cần sử dụng vòng lặp như thế này:

for [$i=0; $i 

Justinb tại Harvest Dot org ¶

17 năm trước

Vincenzo Raco ¶

Philipp Trommler ¶ If the year is specified in a two-digit format, values between 0-69 are mapped to 2000-2069 and values between 70-100 are mapped to 1970-2000.

Aokmikey ¶ Be aware of dates in the m/d/y or d-m-y formats; if the separator is a slash [/], then the American m/d/y is assumed. If the separator is a dash [-] or a dot [.], then the European d-m-y format is assumed. To avoid potential errors, you should YYYY-MM-DD dates or date_create_from_format[] when possible.

người dùng tại máy chủ dot com com

18 năm trước

Htroyo ¶6 năm trước
Giám mục ¶19 năm trước
MPARSA1372 tại Gmail Dot Com ¶1 năm trước

epicxmoe tại gmail dot com

Thí dụPhiên bản PHP:Định nghĩa và cách sử dụng
Phân tích các dữ liệu văn bản tiếng Anh thành dấu thời gian UNIX:
Hãy tự mình thử »
Hàm strtotime [] phân tích dữ liệu văn bản tiếng Anh vào dấu thời gian unix [số giây kể từ ngày 1 tháng 1 năm 1970 00:00:00 gmt].
PHP 5.3.0: Now 24:00 is a valid format
PHP 5.2.7: In earlier versions, if requesting a given occurrence of a given weekday in a month where that weekday was the first day of the month it would incorrectly add one week to the returned timestamp. This has been corrected now
PHP 5.1.0: Returns FALSE on failure [earlier versions returns -1], and issues E_STRICT and E_NOTICE time zone errors
PHP 5.0.2: Now correctly computes "now" and other relative times from current time, not from today's midnight
PHP 5.0.0: Allows microseconds [but they are ignored]

❮ Tham khảo ngày/giờ PHP


[Php 4, Php 5, Php 7, Php 8]

for vòng lặp là các vòng lặp phức tạp nhất trong PHP. Họ cư xử như các đối tác C. Cú pháp của vòng lặp for là:

for [expr1; expr2; expr3]
    statement

Biểu thức đầu tiên [expr1] được đánh giá [thực hiện] một khi vô điều kiện ở đầu vòng lặp.

Khi bắt đầu mỗi lần lặp, expr2 được đánh giá. Nếu nó đánh giá thành

for [$i=0; $i

Bài Viết Liên Quan

Chủ Đề