this means : return the date of the Monday of a specific week from one year <?php $saptamana=$_POST['sapt']; //astea 2 randuri sunt preluarile de date din formular $q=$_POST['anu']; $date = new DateTime(); $date->setDate($q, 1, 1); $ziua=$date->format("N"); /* daca 1 ianuarie e luni */ if($ziua==1) { $w=$saptamana-1; } else { $w=$saptamana-1; if($saptamana==1) { $w=$saptamana-2; } } /*daca e luni si vrem sa aflam prima zi a primei sapt - afisam 1 ianuarie */ if($ziua==1 && $saptamana==1) { $rezultatu=$date->format("Y-n-j"); echo $rezultatu; } else { $date->modify("+$w monday"); $rezultatu=$date->format("Y-n-j"); echo $rezultatu; } echo "<br>"; echo date('d/m/y/W'); ?> PHP: Ignore the comments........
Not sure what you're trying to do exactly... Do you mean like get the Monday in the 43rd week in the year? Or get the Monday closest to a given date?
yep, the 23rd, 43rd, 33rd ..... or 1st of one given year. The script works fine now (as lonk as i tested it) but i want to know if there's a standard way to get this with php. I get the variables (year and number of the week) from a for via POST in this example ...