RE: [PHP] Problem!
| From: | Benjamin Munoz | Date: | Tue, 30 Jan 2001 01:44:30 +0000 |
| Subject: | RE: [PHP] Problem! | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-37201@lists.php.net to get a copy of this message | ||
Stephen,
If this date format is coming from a MySQL database (frequently the case),
you might want to look at the date formatting functions of MySQL.
http://www.mysql.com/doc/D/a/Date_and_time_functions.html.
ex. select DATE_FORMAT('1997-10-04 22:23:00', '%W %M %Y');
One drawback is that this is not standard SQL, so it's not too portable, if
you are concerned with that.
-Ben
-----Original Message-----
From: Stephan Ahonen [mailto:analogy@wheezebucket.com]
Sent: Monday, January 29, 2001 5:22 PM
To: php-general@lists.php.net
Subject: Re: [PHP] Problem!
<<1.
$date = "20010101";
How could I output 01 01 2001 (or make it 3 variables, like day, month,
year)?>>
$year = substr($date,0,4);
$month = substr($date,4,2);
$day = substr($date,6,2);
...Assuming that the date is stored in yyyymmdd format.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net