note 49169 added to function.date

From: Date: Tue, 18 Jan 2005 22:25:03 +0000
Subject: note 49169 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-83581@lists.php.net to get a copy of this message
<? /* ENGLISH [Inglés]: This Script allows you to know the day of the week (Monday, Tuesday, Wednesday...) when you insert XX day XX month and XX year It will return numbers from 0 to 6, 0 == Sunday, 1 == Monday, 2 == Tuesday . . . 6 == Saturday Enjoy It and have some fun! marting_dc AT yahoo DOT com ESPAÑOL [Spanish]: Este Script determina el día de la semana (Lunes, Martes, Miercoles...) cuando le das XX día XX mes XX año, él determinará que día de la semana será esa fecha. El script devolvera números del 0 al 6; 0 == Domingo, 1 == Lunes, 2 == Martes, 3 == Miércoles . . . 6 == Sábado Espero les sirva marting_dc AT yahoo DOT com */ function dia_semana($dia,$mes,$ano) { if (!strstr($ano/4,'.')) { $cmp = ($ano-2000)/2; if ((6 - $cmp) < 0) { $cmp = 6-($cmp-(floor($cmp/7)*7)); } else { $cmp = 6 - $cmp; } if ($mes > 2 || $mes > 2 && $dia >= 28) { $dia += 1; } } else { $tmp = floor($ano/4)*4; $cmp = ($tmp-2000)/2; if ((6 - $cmp) < 0) { $cmp = 6-($cmp-(floor($cmp/7)*7)); } else { $cmp = 6 - $cmp; } $dia += (365*($ano-$tmp)); $dia += 1; } if ($mes > 1) { $dia += 31; if ($mes > 2) { $dia += 28; } if ($mes > 3) { $dia += 31; } if ($mes > 4) { $dia += 30; } if ($mes > 5) { $dia += 31; } if ($mes > 6) { $dia += 30; } if ($mes > 7) { $dia += 31; } if ($mes > 8) { $dia += 31; } if ($mes > 9) { $dia += 30; } if ($mes > 10) { $dia += 31; } if ($mes > 11) { $dia += 30; } if ($cmp+$dia > 6) { $cmp = ($cmp+$dia-1)-(floor(($cmp+$dia-1)/7)*7); } else { $cmp += $dia-1; } } else { if ($cmp+$dia > 6) { $cmp = ($cmp+$dia-1)-(floor(($cmp+$dia-1)/7)*7); } else { $cmp += $dia-1; } } return $cmp; } $dia_semana = dia_semana($day,$month,$year); ?> ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+49169 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49169&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49169&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49169&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49169&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49169&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+49169&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#83581) next »