date/time issue
Moderator: General Moderators
-
bob_the _builder
- Forum Contributor
- Posts: 131
- Joined: Sat Aug 28, 2004 12:25 am
date/time issue
Hi,
I am using the following to set the time zone difference:
putenv("TZ=Pacific/Auckland");
But when I use now() on insert it places the server local time.
Is there a fix so it uses the above time zone?
Thanks
I am using the following to set the time zone difference:
putenv("TZ=Pacific/Auckland");
But when I use now() on insert it places the server local time.
Is there a fix so it uses the above time zone?
Thanks
-
bob_the _builder
- Forum Contributor
- Posts: 131
- Joined: Sat Aug 28, 2004 12:25 am
-
bob_the _builder
- Forum Contributor
- Posts: 131
- Joined: Sat Aug 28, 2004 12:25 am
-
bob_the _builder
- Forum Contributor
- Posts: 131
- Joined: Sat Aug 28, 2004 12:25 am
- maliskoleather
- Forum Contributor
- Posts: 155
- Joined: Tue May 15, 2007 2:19 am
- Contact:
thats what putenv(); does... sets your local timezone. but only in php. You could change it in the php.ini, but that would still only affect php. If you're working with a database, Its usually considered bad practice to use a timestamp generated by the database, because it wont nessicarally match up with the timestamp provided by php (or any other language).
always set your timestamps in a database using date(); or time();
always set your timestamps in a database using date(); or time();
- aaronhall
- DevNet Resident
- Posts: 1040
- Joined: Tue Aug 13, 2002 5:10 pm
- Location: Back in Phoenix, missing the microbrews
- Contact:
The php.ini timezone value will only be used if the TZ environment variable is empty. putenv() should work, and if it doesn't, adjust the date.timezone directive in php.ini.
-
bob_the _builder
- Forum Contributor
- Posts: 131
- Joined: Sat Aug 28, 2004 12:25 am
Slow off the mark
I guess use:
then make date/time:
then insert:
is the answer?
Thanks
I guess use:
Code: Select all
putenv("TZ=Pacific/Auckland");Code: Select all
$date = date('Y-m-d H:i:s');Code: Select all
$dateThanks
- maliskoleather
- Forum Contributor
- Posts: 155
- Joined: Tue May 15, 2007 2:19 am
- Contact:
exactly.
though you dont nessicarily have to assign a variable.. you could just insert date();.. ie:
and yes, i know the sql is bad/wrong/whatever. just an example 
though you dont nessicarily have to assign a variable.. you could just insert date();.. ie:
Code: Select all
$sql = "INSERT timestamp VALUES(".date('Y-m-d H:i:s').")";php forum, database function now(), not specified which database system ...my guess ist: mysql 
If you want to set the timezone of a mysql server take a look at http://dev.mysql.com/doc/refman/4.1/en/ ... pport.html
If you want to set the timezone of a mysql server take a look at http://dev.mysql.com/doc/refman/4.1/en/ ... pport.html
@olrac
and you got answers in the other thread you've already hijacked.Before Post Read: General Posting Guidelines wrote:5. Do not hijack other people's threads, post your own topic and reference (i.e. link to) the other thread in it.