date_sub çalışmıyor

3 Cevap php

Benim sunucu 5.3 php upgreaded değil gibi (PHP Sürüm 5.2.11 olan) date_sub çalışmıyor.

here is the code: $date = date_create(date('Y-m-d')); date_sub($date, date_interval_create_from_date_string('60 days')); $date1= date_format($date, 'Y-m-d');

ancak (5.3) benim localhost Tamam, ama sunucu (5.2.11).

Nasıl ben bu tarih çıkarma 5.2.11 üzerinde çalışma yapabilirsiniz bana söyleyebilir misiniz?

3 Cevap

Gibi the docs kullanmak demek, DateTime::modify().

$ Tarih1 = date ('Y-m-d', strtotime ("-60 gün"));

çalışıyor :)

EX $ da = 2014/04/01 için

u istediğiniz eksi 6 ay bu kullanırsanız ..

$date = strtotime($da .' -6 months');
$final=date('Y-m-d', $date);

$ son echo;