SORU
8 EYLÜL 2009, Salı


bir tarih için bir gün eklemek

Bir tarih için bir gün eklemek için benim kod daha önce bir tarihe gün ekleme verir: 2009-09-30 20:24:00 gelecek ay için bir gün takla OLMALIDIR ekledikten sonra tarih: 1970-01-01 17:33:29

<?php

    //add day to date test for month roll over

    $stop_date = date('Y-m-d H:i:s', strtotime("2009-09-30 20:24:00"));

    echo 'date before day adding: '.$stop_date; 

    $stop_date = date('Y-m-d H:i:s', strtotime(' 1 day', $stop_date));

    echo ' date after adding one day. SHOULD be rolled over to the next month: '.$stop_date;
?>

Daha önce çok benzer bir kod kullandım, yanlış burada ne yapıyorum?

CEVAP
22 Mart 2013, Cuma


Burada verimli bir cevap buldum, fırsat olmadı hemen cevap 3.5 yıl sonra nakil oldum.

Bunu deneyin :

$date = new DateTime('2000-12-31');

$date->modify(' 1 day');
echo $date->format('Y-m-d') . "\n";

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Edge-CGI 3D Tutorials and more!

    Edge-CGI 3D

    11 HAZİRAN 2013
  • Justin Case

    Justin Case

    3 EKİM 2011
  • Tips On Linux

    Tips On Linu

    26 Temmuz 2008