Ben belirttiğiniz tarihten itibaren bir yıl bir tarih almak için çalışıyorum.
Benim kod şöyle görünür:
$futureDate=date('Y-m-d', strtotime('+one year', $startDate));
Bu yanlış tarih dönüyor. Herhangi bir fikir neden?
Bugünün tarihini bir yıl eklemek için aşağıdakileri kullanın:
$oneYearOn = date('Y-m-d',strtotime(date("Y-m-d", mktime()) . " + 365 day"));
Fveyathe other examples you must initialize $StartingDate with a timestamp value fveyaexample:
$StartingDate = mktime(); // todays date as a timestamp
Bu deneyin
$newEndingDate = date("Y-m-d", strtotime(date("Y-m-d", strtotime($StaringDate)) . " + 365 day"));
veya
$newEndingDate = date("Y-m-d", strtotime(date("Y-m-d", strtotime($StaringDate)) . " + 1 year"));
Bu dize '+one year'
(bu "bir" anlamıyor) ayrıştırmak değil, çünkü strtotime()
, bool(false)
dönüyor. false
daha sonra örtülü integer
timestamp artığını ediliyor 0
. Bu diğer işlevleri tıkıyorum gitmeden önce bool(false)
strtotime()
'ın çıkışı değildir doğrulamak için iyi bir fikirdir.
Değerler Dönüş
Returns a timestamp on success, FALSE otherwise. Previous to PHP 5.1.0, this function would return -1 on failure.