Ben hafta belli bir sayıdan sonra bir tarih bulmak gerekir. Başlangıç tarihi cumartesi ise ben 16 hafta seçerseniz Örneğin, 31 Ekim 2009, ve sonra ben onaltı cumartesi sonra tarih bulmak gerekir.
Şimdiden teşekkürler.
Sen kullanabilirsiniz strtotime:
// Oct 31 2009 plus 16 weeks
echo date('Y-m-d', strtotime('2009-10-31 +16 week')); // outputs 2010-02-20
// next week
echo date('Y-m-d', strtotime('+1 week')); // outputs 2009-11-07
strtotime()
is what you want: it takes an expression and turns it into a date object. Also see date()
a>:
$date = '31 october 2009';
$modification = '+ 16 weeks';
echo date('Y-m-d (l)', strtotime("$date")); //2009-10-31 (Saturday)
echo date('Y-m-d (l)', strtotime("$date $modification")); // 2010-02-20 (Saturday)
Eğer 5.2.0 veya daha sonra PHP kullanarak ediyorsanız, kullanabileceğiniz DateTime class
<?php
$date = new DateTime('31 October 2009'); // This accepts any format that strtotime() does.
// Now add 16 weeks
$date->modify('+16 weeks');
// Now you can output it however you wish
echo $date->format('Y-m-d');
?>
Neden sadece, unix zaman kullanabilirsiniz bundan 7 * 24 * 3600 * 16 çıkarmamız ve sonra ihtiyacınız tarihten içine geri dönüştürmek değil.
This will help with the conversion back: http://php.net/manual/en/function.date.php