RE: [PHP] Re: Using date() function
| From: | John W. Holmes | Date: | Sun, 06 Oct 2002 13:31:12 +0000 |
| Subject: | RE: [PHP] Re: Using date() function | ||
| References: | 1 | Groups: | php.general php.windows |
| Request: | Send a blank email to php-general+get-118995@lists.php.net to get a copy of this message | ||
> Using $entry_date = date('l, d F Y H:i:s',$sql['date']); now gives me
> back Tuesday, 19 January 2038 04:14:07 with ever entry. $sql['date']
is
> a TIMESTAMP and looks like this 20021006141256 in the datebase. It
> should give me Sunday, 06 October 2002 14:12:56..? Wierd eh? Do u know
a
> solution?
No, not weird. MySQL uses a timestamp in the YYYYMMDDHHMMSS format.
Date() is expecting a UNIX timestamp, which is the number of seconds
since Jan 1, 1970.
So... you can either use DATE_FORMAT() in your query, with is the MySQL
equivalent of date(). Look up the format in the manual. Or, you can use
UNIX_TIMESTAMP() in your query to select out the unix timestamp instead
of the mysql timestamp, and then use that value within date() in your
PHP script.
---John Holmes...