Flux rss
Rechercher : dans
Par : Pertinence Date Nom d'utilisateur
Statut : Non résolu

Aide pour amelioration fonction date php

  tigre198, le lundi 4 août 2008 à 17:34:33
Bonjour,
salut a tous
j'ai trouvé cette fonction dans site de php


[Code]
function getWorkingDays($startDate,$endDate,$holidays){
//The total number of days between the two dates. We compute the no. of seconds and divide it to 60*60*24
//We add one to inlude both dates in the interval.
$the_first_day_of_week = date("N",strtotime($startDate));
$the_last_day_of_week = date("N",strtotime($endDate));
for ($i=0;$i<52;$i++)
$nbrJours1[ ] = 0;
if( $the_first_day_of_week > 1 AND $the_last_day_of_week <= 7 )

$days = (strtotime($endDate) - strtotime($startDate)) / 86400 + 1;

$no_full_weeks = floor($days / 7);
$no_remaining_days = fmod($days, 7);

//It will return 1 if it's Monday,.. ,7 for Sunday


//---->The two can be equal in leap years when february has 29 days, the equal sign is added here
//In the first case the whole interval is within a week, in the second case the interval falls in two weeks.
if ($the_first_day_of_week <= $the_last_day_of_week){
if ($the_first_day_of_week <= 6 && 6 <= $the_last_day_of_week) $no_remaining_days--;
if ($the_first_day_of_week <= 7 && 7 <= $the_last_day_of_week) $no_remaining_days--;
}
else{
if ($the_first_day_of_week <= 6) $no_remaining_days--;
//In the case when the interval falls in two weeks, there will be a Sunday for sure
$no_remaining_days--;
}

//The no. of business days is: (number of weeks between the two dates) * (5 working days) + the remainder
//---->february in none leap years gave a remainder of 0 but still calculated weekends between first and last day, this is one way to fix it
$workingDays = $no_full_weeks * 5;
if ($no_remaining_days > 0 )
{
$workingDays += $no_remaining_days;
}

//We subtract the holidays
foreach($holidays as $holiday){
$time_stamp=strtotime($holiday);
//If the holiday doesn't fall in weekend
if (strtotime($startDate) <= $time_stamp && $time_stamp <= strtotime($endDate) && date("N",$time_stamp) != 6 && date("N",$time_stamp) != 7)
$workingDays--;
}

return $workingDays;
}

//Example:

$holidays=array("2006-12-25","2006-12-26","2008-01-01");

echo getWorkingDays("2008-01-01","2008-01-31",$holidays);
/Code
cette fonction va me donne 22 jours en excluant samedi et dimanche de calcul
je cherche a ameliorer cette fonction pour me donner résultat comme suit
vu que les deux dates en janvier
donc j'aurais une resultat come suit
semaine1 : 4 jours
semaine 2 : 5 jours
semaine 3 : 5 jours
semaine 4 : 5 jours
semaine 5: 4 jours


quelqu'un a une idée?
Configuration: Windows 2000
Internet Explorer 6.0
Répondre à tigre198  Signaler ce message aux modérateurs

Résultats pour aide pour amelioration fonction date php

PHP Fonction date (Résolu) Salut les amis, Bon voila mon message cible la fonction date en Php je sais comment elle fonctionne mais j'aimerais l'utiliser d'une facon dont j'ignore comment faire j'explique. J'aimerais faire un site et ajouter sur la... www.commentcamarche.net/forum/affich-3978296-php-fonction-date
Problème script shell - fonction Date (Résolu) Bonjour, Je dois faire un script qui compte le nombre de jours depuis le 01/01/2000, qui sera ma variable pour la comparer a un fichier (qui porte dans son nom le n° d'aujourd'hui) J'ai essayé avec la fonction Date, mais comme je suis... www.commentcamarche.net/forum/affich-5102382-probleme-script-shell-fonction-date
{SQL} foncion DATEDIFF (Résolu) Bonjour a toute la communauté! J'ai dans une fonction sous Access dans un Select, la fonction "DATEDIFF(day, '01/01/01', max(ZWU_HIST.ZWU_DAT_DEM)) AS MaxDeZWU_DAT_DEM". D'après ce site : http://msdn.microsoft.com/fr... www.commentcamarche.net/forum/affich-6919828-sql-foncion-datediff

Résultats pour aide pour amelioration fonction date php

[PHP] Dernier jour du mois / Nombre de jours dans le moisSoient $m le numéro du mois en question et $y l'année. La fonction date() permet d'afficher directement le nombre de jours dans le mois avec le caractère "t" : www.commentcamarche.net/faq/sujet-875-php-dernier-jour-du-mois-nombre-de-jours-dans-le-mois
Warning: rmdir(..): Directory not emptyIntroduction Le code de la fonction (compatible PHP 5 ou supérieur) Mise en garde pour la sécurité Introduction Lorsque vous tentez d'effacer un dossier en PHP, il peut arriver que vous rencontriez l'erreur suivante: Warning: rmdir(..):... www.commentcamarche.net/faq/sujet-12255-warning-rmdir-directory-not-empty
[PHP] Date de dernière modificationGrâce à PHP il est possible d'afficher automatiquement la date de dernière modification de la page en cours : ... www.commentcamarche.net/faq/sujet-851-php-date-de-derniere-modification

Résultats pour aide pour amelioration fonction date php

La fonction date() (Résolu)Bonjour, je viens de créer un site web avec php , disposant d'une db mysql , seulement j'ai un champs qui doit prendre la date du jour. j'ai utilisé la fonction date pour recuperer la variable , sauf que je me retrouve avec des 0000-00... www.commentcamarche.net/forum/affich-8354436-la-fonction-date
[php] fonction date lol (Résolu)Bonjour, voici mon problème ma fonction date me renvoie toujours la même date : 01/01/1970 mon code: echo date('d/m/Y à H\hi', $enregistrement['date']); dans ma base de donnée date est un champs de type bigint. www.commentcamarche.net/forum/affich-5010789-php-fonction-date-lol
Différence entre fonction datediff et int (Résolu)Bonjour à tous, Quelqu'un pourrait il me dire quelle est la différence entre la fonction "datediff" et la fonciton "int" en excel 2003 Je vous remercie d'avance E www.commentcamarche.net/forum/affich-8750873-difference-entre-fonction-datediff-et-int

Résultats pour aide pour amelioration fonction date php

PHP - Affichage de texte sur le navigateurLe but de PHP est de permettre la création de pages web dynamiques, ainsi son but premier est de pouvoir envoyer des données au navigateur. Les trois fonctions standards PHP fournit 3 fonctions permettant d'envoyer du texte au navigateur. Ces... www.commentcamarche.net/contents/php/phpaffich.php3
PHP - Mail et fonctions réseauPHP étant un langage consacré au Web, il possède bien évidemment des fonctions lui permettant de communiquer avec le "monde extérieur" à l'aide de fonctions standards. Le service le plus utilisé sur Internet étant la messagerie électronique, il est... www.commentcamarche.net/contents/php/phpmail.php3
VBScript - Les fonctions de date et de tempsLes fonctions de date et de temps Fonction Description Date Retourne la date du système DateAdd(interval, number, date) Ajoute un intervalle de temps (interval) à une... www.commentcamarche.net/contents/vbscript/vbs-fonctions-date.php3