Me revoila, j'ai trouvé ce code après un long moment de recherche.
Correspond-t-il a ce que je cherhce ?!
Code : --->
If you want to get the date of a given day in a week, this might be useful. (I.e. you want to know what is the date of Friday in week 20 of 2004)
This code was converted from Delphi source code and has been tested. No guarantees however
<?php
# Get a date by providing a week number, day of week and a year.
# Be careful! There are different definitions for weeks. Here the European definition is used.
# In Europe a week starts on Monday.
# Also the start of the first week in a year is defined differently in different countries.
# Here the ISO 8601 definition is used. This is the standard in Europe.
#
# I got the information from
http://home.t-online.de/home/PeterJHaas/delphi.htm
# There are many websites with information on week numbers.
# An excellent site on this subject is
http://www.pjh2.de/datetime/weeknumber/index.php
#
# This PHP source was based on the Delphi source code by Peter J. Haas
#
//give me the date of Friday week 20 of the year 2004 (Should result in Friday May 14 2004)
$aWeek=20; $aDay=05; $aYear=2004;
$adate=datefromweeknr($aYear, $aWeek, $aDay);
echo 'The date (week='.$aWeek.' day='.$aDay.' year= '.$aYear.') is '.date('D d-m-Y',$adate).'<br>';
function datefromweeknr($aYear, $aWeek, $aDay)
{
$FirstDayOfWeek=1; //First day of week is Monday
$BaseDate=4; //We calculate from 4/1 which is always in week 1
$CJDDelta=2415019; //Based on start of Chronological Julian Day
$StartDate = DelphiDate(mktime(1,0,0,01,$BaseDate,$aYear)); //The date to start with
$Offset = ($aWeek-1) * 7 - mod(floor($StartDate) + $CJDDelta + 8 - $FirstDayOfWeek,7) + $aDay - 1;
return PHPUnixTimeStamp($StartDate + $Offset);
}
#---------extra functions used----------
function DelphiDate($aPHPTime)
{
# The Unix Timestamp holds the number of seconds after January 1 1970 01:00:00
return div($aPHPTime,86400)+25569;
}
function PHPUnixTimeStamp($aDelphiDate)
{
# Delphi's TDate holds number of days after December 30 1899
return ($aDelphiDate-25569)*86400-3600;
}
function mod($number, $div)
{
return $number - floor($number/$div)*$div;
}
function div($number, $div)
{
return floor($number/$div);
}
?>