note 105603 deleted from function.strtotime by derick

From: Date: Sun, 14 Dec 2014 11:38:56 +0000
Subject: note 105603 deleted from function.strtotime by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-201183@lists.php.net to get a copy of this message
Note Submitter: hushuilong at gmail dot com ---- There is a bug when around a month change. The bug url: https://bugs.php.net/bug.php?id=27793 To work around this ,check the method below : Pass the timestamp of the first second on the first day in current month to strtotime the second parameter. <?php date_default_timezone_set('Asia/Shanghai'); $first_day_of_month = date('Y-m',time()) . '-01 00:00:01'; $t = strtotime($first_day_of_month); print_r(array( date('Y-m',$t), date('Y-m',strtotime('- 1 month',$t)), date('Y-m',strtotime('- 2 month',$t)), )); ?>

« previous php.notes (#201183) next »