Re: month
| From: | Justin French | Date: | Tue, 01 Apr 2003 09:49:22 +0000 |
| Subject: | Re: month | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-141797@lists.php.net to get a copy of this message | ||
on 01/04/03 9:16 PM, Diana Castillo (diana@interhotel.com) wrote:
> how do you get just the month (in numeric format ) of a specific date. (not
> today)
> same for day and year. The date is in yyyy-dd-mm format to start with.
> thanks.
If your date was yyyy-mm-dd, you could do this:
<?
$date = '2002-03-18';
echo date('m', strtotime($date));
?>
But, because yours isn't:
<?
$date = '2002-03-18';
list($y,$d,$m) = explode('-',$date);
echo date('m', strtotime("{$y}-{$m}-{$d}"));
?>
Justin