View Single Post

   
  #7 (permalink)  
Old 03-20-2008, 01:47 PM
Captain Paralytic
 
Posts: n/a
Default Re: Store Local Time

On 18 Mar, 12:40, "Peter H. Coffin" <hell...@ninehells.com> wrote:
> On Tue, 18 Mar 2008 04:11:34 -0700 (PDT), Captain Paralytic wrote:
> > On 18 Mar, 10:36, Anees <muhd.an...@gmail.com> wrote:
> >> > Store using UTC_TIMESTAMP and convert to local time when accessing.

>
> >> The field description given, when i created the table was

>
> >> cur_time timestamp CURRENT_TIMESTAMP

>
> >> So u r telling instead of inserting the current time automatically, i
> >> need to pass the value after calling UTC_TIMESTAMP from PHP?

>
> > No, UTC_TIMESTAMP() is a MySQL function, not a php function. I am
> > telling you to use this to insert the current time automatically.

>
> Unfortunately for Anees, this will not get exactly what is wanted, which
> is local time in Dubai.

This part out of context will not, but I believe that my actual
solution posted in my original reply will supply what was requested.

> It will, however, remove whatever local time
> bais exists. It does also complicate the coding somewhat

It will change the coding certainly. But I do not think it will become
particularly complex. One just needs to follow the correct syntax for
one's needs.

> in that the
> UTC_TIMESTAMP doesn't seem usable as a DEFAULT value at least on 5.0,
>
> create table `test`.`utc_test` (
> `rec_seq` int NOT NULL ,
> `val` varchar NULL ,
> `last_update` timestamp DEFAULT UTC_TIMESTAMP ,
> `created_at` timestamp DEFAULT UTC_TIMESTAMP ,
> PRIMARY KEY ( `rec_seq` )
> )
>
> Error Code : 1064
> You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULL ,
> `last_update` timestamp DEFAULT UTC_TIMESTAMP ,
> `created_at' at line 3
> (0 ms taken)

This error refers to you having missed the field size from the
VARCHAR, it has nothing to do with the use of UTC_TIMESTAMP.

>
> and the auto-update function may be problematic.

What auto-update function?
Reply With Quote