Re: Holding "datetimes" in a DB.

From: Date: Sat, 02 Mar 2013 05:35:53 +0000
Subject: Re: Holding "datetimes" in a DB.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-320349@lists.php.net to get a copy of this message
On Fri, Mar 1, 2013 at 9:49 PM, Richard Quadling <rquadling@gmail.com> wrote: > Hi. > > My heads trying to remember something I may or may not have known to start with. > > If I hold datetimes in a DB in UTC and can represent a date to a user > based upon a user preference Timezone (not an offset, but a real > timezone : Europe/Berlin, etc.) am I missing anything? Perhaps the "best" alternative is to store the data in the DB in a datatype that includes timezone, eg "timestamp with timezone" http://www.postgresql.org/docs/9.1/static/datatype-datetime.html That way you can let the DB take care of any conversions when you need it, ie you can insert using Europe/Berlin and then select using UTC (etc etc). If you are just quickly writing your app for one timezone you can have that as the 'default' but then if you want to expand later then all your data is already in the most useful format. Paul Paul

« previous php.general (#320349) next »