Jump to content

Recommended Posts

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/yy

03/25/06 becomes after applying strtotime 1143237600 and $zi becomes Saturday
03/26/06 becomes after applying strtotime 1143320400 and $zi becomes Saturday instead of Sunday

Does 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
Link to comment
https://forums.phpfreaks.com/topic/5545-strtotime/
Share on other sites

[!--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/yy

03/25/06 becomes after applying strtotime 1143237600 and $zi becomes Saturday
03/26/06 becomes after applying strtotime 1143320400 and $zi becomes Saturday instead of Sunday

Does 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-1

php.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.

Link to comment
https://forums.phpfreaks.com/topic/5545-strtotime/#findComment-19792
Share on other sites

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');
Link to comment
https://forums.phpfreaks.com/topic/5545-strtotime/#findComment-19795
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.