Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

218
Views
Sort data display last 30 days data with foreach PHP

i will sort data display last 30 days data with foreach with PHP.

This my code:

for($i = 0; $i < 30; $i++) {
       echo  date("Y-m-d", strtotime('-'. $i .' days')).'<br>';
   }

this is the result:

2021-10-07
2021-10-06
2021-10-05
2021-10-04
2021-10-03
2021-10-02
2021-10-01
2021-09-30
2021-09-29
2021-09-28
2021-09-27
2021-09-26
2021-09-25
2021-09-24
2021-09-23
2021-09-22
2021-09-21
2021-09-20
2021-09-19
2021-09-18
2021-09-17
2021-09-16
2021-09-15
2021-09-14
2021-09-13
2021-09-12
2021-09-11
2021-09-10
2021-09-09
2021-09-08

Then I want to sort the data from the oldest date to the new date. From 2021-09-08 to 2021-10-07.

how to do it, is there any other solution?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Check this out

for($i = 30; $i >= 0; $i--) {
       echo  date("Y-m-d", strtotime('-'. $i .' days')).'<br>';
}

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!