-2

I am thingking if how to get all the date of weekdays between a given date

example: I have a date given 2013-01-01 and 2013-20-01

It must return all date of weekdays like 2013-01-01

how could this be done using php thankz

Keydi
  • 21
  • 3
  • 6

2 Answers2

2

Look into DatePeriod Class, this is available from PHP 5.3.

Here is an example from the site

$begin = new DateTime( '2012-08-01' );
$end = new DateTime( '2012-08-31' );
$end = $end->modify( '+1 day' );

$interval = new DateInterval('P1D');
$daterange = new DatePeriod($begin, $interval ,$end);

foreach($daterange as $date){

       // You can manipulate the date here
    echo $date->format("Ymd") . "<br>";
}
Starx
  • 77,474
  • 47
  • 185
  • 261
0

You can get the weekday from the timestamp using the multitude of formatting options avalaible:

echo date("D",strtotime("2013-01-01"));

tues

enkdr
  • 363
  • 5
  • 15