Re: Yes, a newbie and a date question
| From: | David Otton | Date: | Fri, 16 May 2003 18:02:45 +0000 |
| Subject: | Re: Yes, a newbie and a date question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-147946@lists.php.net to get a copy of this message | ||
On Fri, 16 May 2003 13:39:09 -0400, you wrote:
>Greetings, list! I am new to PHP and MySQL, though not to programming (big
>iron machines). I have been stumbling for a while now on a date problem. I
>have a MySQL database setup where I need to display a shipdate to the user.
>I need the date and the day of week in separate fields.
>
>I want to convert the MySQL timestamp field to 5/15/2003 and "Friday".
>
>My date value is stored as a MySQL timestamp value, length 14.
>
>The results of the following code is as follows:
>
>Ship Date n/j/Y Day of Week Timestamp Value
>1/18/2038 Monday 20030103000000
>1/18/2038 Monday 20030103000000
>1/18/2038 Monday 20030103000000
>1/18/2038 Monday 20030123000000
>1/18/2038 Monday 20030217000000
>
>How can I get the date() function to pick up the 20030103, not the 000000?
To convert a MySQL timestamp into a UNIX timestamp
SELECT UNIX_TIMESTAMP(sdshipd) FROM shipdetail;
From that point, use the PHP date/time functions
http://www.php.net/manual/en/ref.datetime.php
eg
echo (date("l d/m/y"));
[untested code, from memory]