SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
-
Oct 29, 2006, 21:34 #1
- Join Date
- Apr 2005
- Posts
- 86
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Convert string date to array format
I am wondering how I would convert a string such as Jan 1 1980 12:00AM to an array like the following:
Array (
[m] => 1
[d] => 1
[Y] => 1980
)
The string above is just an example. In practise the month, date and year could be anything, but the time will always be 12:00AM. As the array shows I am not interested in keeping the time information, just in splitting the string to the correct array format.
Do you know how to do that? Is there a PHP function that would do such a thing?
thAnks.
-
Oct 29, 2006, 21:48 #2
- Join Date
- Mar 2006
- Posts
- 6,132
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
PHP Code:$months = array(
'Jan' => 1,
'Feb' => 2,
// etc...
);
list ($m, $d, $y) = explode(' ', $foo);
$array = array('m' => $months[$m], 'd' => $d, 'y' => $y);
Bookmarks