-5

I've seen the answer to this question but, if I apply it to my code, I get the following error:

Warning: date() expects parameter 2 to be long, object given

This is my code:

while (date('N', $EndDate2)>=6){
    ...do stuff..;
}

Note: $EndDate2 is an object date

genespos
  • 3,071
  • 5
  • 34
  • 66

1 Answers1

1

date() operates against timestamps, rather than DateTime objects. You should use the format method of the object instead (it takes the same formatting arguments):

if ($EndDate2->format('N') >= 6) {
  ...
}
iainn
  • 16,011
  • 9
  • 29
  • 38