rocketman Posted March 22, 2006 Share Posted March 22, 2006 I have the following code:[code]$zi = date("l",strtotime($zi_de_calculat));[/code]Where $zi_de_calculat it's a date in the format mm/dd/yy03/25/06 becomes after applying strtotime 1143237600 and $zi becomes Saturday03/26/06 becomes after applying strtotime 1143320400 and $zi becomes Saturday instead of SundayDoes anyone know the solution to this problem or the cause.Note: For all the other days of the week works just fine, only Sunday is replaced by Saturday.Thx Quote Link to comment https://forums.phpfreaks.com/topic/5545-strtotime/ Share on other sites More sharing options...
redarrow Posted March 22, 2006 Share Posted March 22, 2006 [!--quoteo(post=357436:date=Mar 22 2006, 11:33 PM:name=Rocketman)--][div class=\'quotetop\']QUOTE(Rocketman @ Mar 22 2006, 11:33 PM) [snapback]357436[/snapback][/div][div class=\'quotemain\'][!--quotec--]I have the following code:[code]$zi = date("l",strtotime($zi_de_calculat));[/code]Where $zi_de_calculat it's a date in the format mm/dd/yy03/25/06 becomes after applying strtotime 1143237600 and $zi becomes Saturday03/26/06 becomes after applying strtotime 1143320400 and $zi becomes Saturday instead of SundayDoes anyone know the solution to this problem or the cause.Note: For all the other days of the week works just fine, only Sunday is replaced by Saturday.Thx[/quote][code]In PHP 4.3.10(Suse Linux 9.2) strtotime() seems to sometimes resolve incorrect month values.e.g.:<? $day = strftime ("%d", strtotime("-$day days")); $month = strftime ("%m", strtotime("-$day days")); $year = strftime ("%Y", strtotime("-$day days"));?>Result: $month is sometimes: expected month-1php.net bug-reporting systems says: "problem will be fixed in php5 not any londer in php4!".Workarround in php4 to savely get the correct values for example above:<? $date = strftime ("%d.%m.%Y", strtotime("-$day days")); list($day, $month, $year) = split('[/.]', $date);?> [/code]ps [!--sizeo:5--][span style=\"font-size:18pt;line-height:100%\"][!--/sizeo--]read[!--sizec--][/span][!--/sizec--][a href=\"http://uk.php.net/strtotime\" target=\"_blank\"]http://uk.php.net/strtotime[/a]good luck. Quote Link to comment https://forums.phpfreaks.com/topic/5545-strtotime/#findComment-19792 Share on other sites More sharing options...
rocketman Posted March 22, 2006 Author Share Posted March 22, 2006 Found the solution using MySQL//This will return the day of the week in numerical format (i.e. "0" Monday to "6" Sunday) SELECT WEEKDAY('2003-01-01');//This will return the day of the week in numerical format (i.e. "1" Sunday to "7" Saturday) SELECT DAYOFWEEK('2003-01-01'); Quote Link to comment https://forums.phpfreaks.com/topic/5545-strtotime/#findComment-19795 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.