RE: Re[2]: [PHP] MySQL timestamp to desired date function
| From: | Cody Phanekham | Date: | Thu, 18 Sep 2003 05:57:30 +0000 |
| Subject: | RE: Re[2]: [PHP] MySQL timestamp to desired date function | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-162958@lists.php.net to get a copy of this message | ||
I'd have to agree with Tom, it would be better to do the formatting using the DB since MySQL
stores its timestamp differently than the UNIX timestamp.
however, if you really want to do it in PHP you can use MySQL's function UNIX_TIMESTAMP() to
convert the db timestamp to a unix timestamp, then use PHP's date() function to display the
date.
so the code would look something like:
$sql = "SELECT UNIX_TIMESTAMP(lugar_lastinsert) from <table name> where
<condition>";
.. db query code here
$row = mysql_fetch_array($result);
echo date("r", $row[0]);
> what database are you using?
I was wondering this as well, until i checked the subject
> It may be better to let the db do the formatting for you.
>
> --
> regards,
> Tom
*************************************************************************************
This e-mail, including any attachments to it, may contain confidential and/or personal information.
If you have received this e-mail in error, you must not copy, distribute, or disclose it, use or
take any action
based on the information contained within it.
Please notify the sender immediately by return e-mail of the error and then delete the original
e-mail.
The information contained within this e-mail may be solely the opinion of the sender and may not
necessarily
reflect the position, beliefs or opinions of Salmat on any issue.
This email has been swept for the presence of computer viruses known to Salmat's anti-virus
systems.
For more information, visit our website at www.salmat.com.au.
*************************************************************************************