note 114279 deleted from function.strtotime by derick
| From: | derick@php.net | Date: | Sun, 14 Dec 2014 11:25:20 +0000 |
| Subject: | note 114279 deleted from function.strtotime by derick | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-201153@lists.php.net to get a copy of this message | ||
Note Submitter: gffabio at hotmail dot com
----
una solucion al para saber el primer y ultimo dia del mes siguiente
<?php
$fecha = '2014-01-31';
//resultado incorrecto
echo date('Y-m-01',strtotime("$fecha next
month")).'<br>';//2014-03-01
echo date('Y-m-t',strtotime("$fecha next
month")).'<br>';//2014-03-31
//correcto
echo date('Y-m-01',strtotime("$fecha last day of next
month")).'<br>';//2014-02-01
echo date('Y-m-t',strtotime("$fecha last day of next
month")).'<br>';//2014-02-28
$fecha = '2014-05-31';
//resultado incorrecto
echo date('Y-m-01',strtotime("$fecha next
month")).'<br>';//2014-07-01
echo date('Y-m-t',strtotime("$fecha next
month")).'<br>';//2014-07-31
//correcto
echo date('Y-m-01',strtotime("$fecha last day of next
month")).'<br>';//2014-06-01
echo date('Y-m-t',strtotime("$fecha last day of next month"));//2014-06-28
?>