Re: PHP date returns wrong value ??
| From: | Jason Wong | Date: | Sun, 16 Jan 2005 13:29:34 +0000 |
| Subject: | Re: PHP date returns wrong value ?? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-206479@lists.php.net to get a copy of this message | ||
On Sunday 16 January 2005 15:22, Michael Gale wrote:
Not a direct answer to your problem ...
> $query="INSERT INTO tentry_table SET ticket_id = '" . $ticket .
> "',";
> $query .= " tentry_date = '" . date("Y-m-d") . "',";
> $query .= " tentry_time = '" . date("H:j:s") . "',";
1) When doing something involving date/time it is best practice to assign
date/time *once* to a variable then work off of that variable. This ensures
that your date/time is consistent withing that block of code.
2) If there is no particular reason why you are storing the date and the time
separately why not just use a DATETIME field? Then you can just use the
builtin db function NOW(). Or, if that datetime never changes once assigned,
you could even use a TIMESTAMP field.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
New Year Resolution: Ignore top posted posts