A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2009 yearA PostgreSQL timestamp field not formated in the same way when updated with PHP - page 1
User InfoPosts
A PostgreSQL timestamp field not formated in the same way when updated with PHP#1
I have a timestamp with timezone field in PostgreSQL.
When I update this field, I use something like this:

$date = date((Y-m-d H:i:s();


Although the SQL works fine, the date saved seem a little bit different to a classic timestamp with timezone date.

Example:

Default value set to "now()":
date 2009-04-06 14:39:53.662522+02

Update with a date set in php:
$date = date((Y-m-d H:i:s();
date 2009-04-06 14:39:53+02


The numbers removed on update are probably milliseconds but I(m not sure.
I would like to know if there is a means to obtain with PHP the same format of date?

posted date: 2009-04-06 12:05:00


Re: A PostgreSQL timestamp field not formated in the same way when updated with PHP#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2009-04-06 12:05:01


Re: A PostgreSQL timestamp field not formated in the same way when updated with PHP#3
You can use the microtime() PHP function to get the microseconds.

posted date: 2009-04-06 12:48:00


Re: A PostgreSQL timestamp field not formated in the same way when updated with PHP#4
If you only need one second resolution of timestamp you have to design your database accordingly, as by default resolution is better than a second.Use for example the following column definition:last_access_time timestamp with time zone not null default date_trunc((second(,now()) constraint last_access_time_full_second check ( date_trunc((second(,last_access_time)=last_access_time )

posted date: 2009-04-07 00:13:00


Re: A PostgreSQL timestamp field not formated in the same way when updated with PHP#5
Fortunatelly the column definition could be much simpler (at least the part for the default value): last_access_time timestamp(0) with time zone default CURRENT_TIMESTAMP

posted date: 2009-04-07 05:27:00


select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.