You are here: Re: mktime not working correctly « PHP Programming Language « IT news, forums, messages
Re: mktime not working correctly

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация