php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19847 day of weeks on october month
Submitted: 2002-10-10 08:23 UTC Modified: 2002-10-26 01:00 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: davis at suldigital dot com dot br Assigned:
Status: No Feedback Package: Date/time related
PHP Version: 4.2.3 OS: BSD
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: davis at suldigital dot com dot br
New email:
PHP Version: OS:

 

 [2002-10-10 08:23 UTC] davis at suldigital dot com dot br
I have same code:
function dia_semana($dia, $mes, $ano)
{
	$dia_semana = date("D", mktime(0,0,0,$mes,$dia,$ano));
	switch($dia_semana)
	{
		case "Sun": return "Domingo"; break;
		case "Mon": return "Segunda-Feira"; break;
		case "Tue": return "Ter?a-Feira"; break;
		case "Wed": return "Quarta-Feira"; break;
		case "Thu": return "Quinta-Feira"; break;
		case "Fri": return "Sexta-Feira"; break;
		case "Sat": return "S?bado"; break;
		default: die("Erro com dia da semana");
	}
}

when I try to print days of week in October with

if($mes==2) 
	$dias_mes = 28;
else if($mes==4||$mes==6||$mes==9||$mes==11) 
	$dias_mes = 30;
else
	$dias_mes = 31;
$real_acum_p1=0;
$i=1;
while($i<=$dias_mes)
{		

	//pega dia da semana
	echo $i." ".date("D", mktime(0,0,0,$mes,$i,$ano)) . " : ";
	echo $dia_semana = dia_semana($i, $mes, $ano) . "<br>";
	$i++;
}

returns
...
11 Fri : Sexta-Feira
12 Sat : S?bado
13 Wed : Quarta-Feira
14 Mon : Segunda-Feira
15 Tue : Ter?a-Feira
...

after sat, should be Sun, right?

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-10-10 08:58 UTC] sniper@php.net
First of all: Give us a fully working and complete script
which can be easily copy pasted..I tried with similar
script and it works fine here.



 [2002-10-10 09:13 UTC] davis at suldigital dot com dot br
I have same code:

<?

function dia_semana($dia, $mes, $ano)
{
	$dia_semana = date("D", mktime(0,0,0,$mes,$dia,$ano));
	switch($dia_semana)
	{
		case "Sun": return "Domingo"; break;
		case "Mon": return "Segunda-Feira"; break;
		case "Tue": return "Ter?a-Feira"; break;
		case "Wed": return "Quarta-Feira"; break;
		case "Thu": return "Quinta-Feira"; break;
		case "Fri": return "Sexta-Feira"; break;
		case "Sat": return "S?bado"; break;
		default: die("Erro com dia da semana ".$dia_semana);
	}
}

$mes = 10; //month
$ano = 2002; //year

if($mes==2) 
	$dias_mes = 28;
else if($mes==4||$mes==6||$mes==9||$mes==11) 
	$dias_mes = 30;
else
	$dias_mes = 31;
$i=1;
while($i<=$dias_mes)
{		
	if($i==13) echo "<b style='color:red'>";
	echo $i." ".date("D", mktime(0,0,0,$mes,$i,$ano)) . " : ";
	echo $dia_semana = dia_semana($i, $mes, $ano) . "<br>";	
	if($i==13) echo "</b>";
	$i++;
}

?>

output is:

...
11 Fri : Sexta-Feira
12 Sat : S?bado
13 Wed : Quarta-Feira
14 Mon : Segunda-Feira
15 Tue : Ter?a-Feira
...

can see a exmple in http://www.suldigital.com.br/davis/rodcat/teste.php
 [2002-10-10 09:35 UTC] derick@php.net
We are happy to tell you that you just discovered Daylight Savings
Time. For more information see:
http://webexhibits.org/daylightsaving/b.html
 [2002-10-10 10:58 UTC] pguillot at paanjaru dot com
Hi,

On a rh7.3 with php 4.1.2 ( from rpm ) the result of the script is ok :
11 Fri : Sexta-Feira
12 Sat : S?bado
13 Sun : Domingo
14 Mon : Segunda-Feira
15 Tue : Ter?a-Feira
16 Wed : Quarta-Feira

Patrick
 [2002-10-10 11:39 UTC] davis at suldigital dot com dot br
and what is this derick?
 [2002-10-10 15:00 UTC] derick@php.net
sorry, reopening. Can anybody else on BSD verify this? 
Which BSD version do you exactly have?

Derick
 [2002-10-10 15:32 UTC] msopacua@php.net
Can't verify on FreeBSD 4.6-RELEASE, BSD/OS 4.1, BSD/OS 4.2.

davis@sudligital.com.br:
In addition to the BSD version, what is the locale string for your platform (env | grep LC_)?

I also modified it, to force DLS on the correct date, but doesn't have any impact:
$ sapi/cli/php -f ./date.php 
mes/ano: Oct/2002

1 Tue : Ter?a-Feira (0) 
2 Wed : Quarta-Feira (0) 
3 Thu : Quinta-Feira (0) 
4 Fri : Sexta-Feira (0) 
5 Sat : S?bado (0) 
6 Sun : Domingo (1) 
7 Mon : Segunda-Feira (1) 
8 Tue : Ter?a-Feira (1) 
9 Wed : Quarta-Feira (1) 
10 Thu : Quinta-Feira (1) 
11 Fri : Sexta-Feira (1) 
12 Sat : S?bado (1) 
13 Sun : Domingo (1) 
 [2002-10-26 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over 2 weeks, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 12:01:27 2024 UTC