Re: PHP date returns wrong value ??

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux