Re: month

From: Date: Tue, 01 Apr 2003 10:32:38 +0000
Subject: Re: month
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-141795@lists.php.net to get a copy of this message
At 12:16 1-4-03, you 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 you obtain it directly you should try to alter the way you get the date.
If it is from e.g. a database or something, you can choose: $date="2003-04-01"; example 1: $date_elements = explode ('-',$date); echo "The date has exploded in a day {$date_elements[2]}, a month {$date_elements[1]} and the year{$date_elements[0]}."; example 2:
echo 'The date is '     .substr($date, 8,2). '(day)'
                        .substr($date, 5,2). '(month)'
                        .substr($date, 0,4). '(year)';
(I'm not 100% sure about the 8 and the 5 ) Chris H.

« previous php.general (#141795) next »