|
Posted by Steve on 11/30/48 11:28
> This code has worked correctly before sept 30, after this day, I should
> have had weekday=6, then 7, then 1 again, but after 5 I get 3, and so on
Interesting... there's some subtle change in behaviour with mktime()
that depends on whether you use leading 0's in the month. Changing from
September (month '09' in your code) to October (month '10') switches
from one behaviour to the other. The change involves making an
assumption about what day the week starts on (American vs European?)
So I think your code just needs to be adjusted to consistently force
the use of the second behaviour, by casting the month to an integer:
// $weekday: 1=Monday/Lunedi, 2=Tuesday/Martedi, ..., 7=Sunday/Domenica
$data=$record['Data_Visita']; // year-month-day date format
$anno = intval( substr($data,1,4) );
$mese = intval( substr($data,6,2) );
$giorno = intval( substr($data,8,2) );
$utime = mktime(0,0,0, $mese,$giorno,$anno,-1);
$weekday = date('w',$utime);
echo $weekday . "\n";
See the user note by <daykay at pdsoftware dot de> on the date()
manpage <http://www.php.net/manual/en/function.date.php>
---
Steve
Navigation:
[Reply to this message]
|