RE: [PHP] Timestamp math and format
| From: | Don Read | Date: | Thu, 18 Oct 2001 01:24:24 +0000 |
| Subject: | RE: [PHP] Timestamp math and format | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-71432@lists.php.net to get a copy of this message | ||
On 17-Oct-2001 Alfredeen Johan K wrote:
> I store a timestamp in a database of when a record was inserted. When I pull
> it out, I format it like this SELECT DATE_FORMAT(insert_date,'%b %e (%r)')
> AS idate
>
> Now I would like to subtract 2 hours from the hour part of the timestamp.
> What's the easiest way to do this, before or after the formatting? In PHP or
> mySQL function? Can someone give me some code of how they would do this.
>
SELECT DATE_FORMAT(DATE_SUB(insert_date, INTERVAL 2 HOUR), '%b %e (%r)')
Regards,
--
Don Read dread@texas.net
-- It is necessary for me to learn from others' mistakes. I
will not live long enough to make them all by myself.