Akılda tutulması gereken bir şey olduğunu strtotime()
function is very robust and can give you fuzzy information like the second Sunday in March ("Second Sunday March 0"
) a>.
Örneğin, bu ayın ikinci haftasında işaretleri Pazar bulmak için
<?php
$month = time();
// Calculate the first day of the month contained in the $month timestamp
$first_day = strtotime(
date(
'Y-m-1 00:00:00',
$month
)
);
// Calculate the sunday opening the week that contains the first day
// of the month (e.g. August 30th, 2009 is the Sunday that corresponds
// to September 1st, 2009)
$pseudo_first_sunday = strtotime(
'First Sunday',
strtotime(
'-1 Week',
$first_day
)
);
var_dump(date( 'Y-m-d', strtotime('Second Week', $pseudo_first_sunday) ));
: Bu betiğin çıktısı (2009/09/14 itibariyle) olacak
string(10) "2009-09-06"
Eylül ayının ikinci haftasında olduğu (ancak ikinci FULL hafta, sizin için o yerine $first_day
istiyorsanız $pseudo_first_sunday
).
PHP tarihleri ile oynarken Sadece bir şey akılda tutmak.