note 22667 added to function.time
| From: | mwwaygoo at hotmail dot com | Date: | Wed, 26 Jun 2002 13:16:28 +0000 |
| Subject: | note 22667 added to function.time | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-32221@lists.php.net to get a copy of this message | ||
If you are storing the date and time in a MySql database, I have found storing the time stamp as an
INTEGER difficult to read when checking through the raw data. You can save a time-stamp into a
datetime type and it becomes readable.
BUT when you retrieve the data it comes back as 2000-06-05 12:15:01.
Make sure your select queries use the date in this format, otherwise they give bad results, and
format your retrieved entries so they are usable.
e.g.
This will give the individual entries
$my_date="2002-06-26 13:30:00";
list($year,$month,$day,$hour,$min,$sec)=explode(":", eregi_replace("['
'|-]",":", $my_date));
This will format your timestamp into a format used in your queries
$sql_query = "SELECT ... WHERE valid_until>=1025092140";
change to :
$sql_query = "SELECT ... WHERE valid_until>='" . date("Y-m-d
H:i:s",1025092140) . "'";
--
http://www.php.net/manual/en/function.time.php
http://master.php.net/manage/user-notes.php?action=edit+22667
http://master.php.net/manage/user-notes.php?action=delete+22667
http://master.php.net/manage/user-notes.php?action=reject+22667