Web Hosting Vodahost    

Home Take The Royal Tour! Order Now Features Prices
Go Back   Web Hosting > VodaHost Web Hosting Support > mySQL & PHP

Notices

mySQL & PHP Discussions, information and help with mySQL and PHP.

Reply
 
LinkBack Thread Tools
  #1  
Old 11-27-2007, 11:24 PM
pipesportugal's Avatar
Second Lieutenant
 
Join Date: Jul 2007
Location: Oporto - Portugal
Posts: 101
Default VH timezone server-mySQL function now()

Hello dear friends from the VH forum,

I am using the sentence "now()" on an UPDATE mySQL query to update a field on the table that will provide me with last login (date and time) of a certain user. This recorded date/time is not correct for me.

My question is:
Is there a way through the VH control panel to change my "prefered" timezone to GMT (since I am in Portugal) or am I forced to make calculations and add the necessary time to adapt the given "now()" date/time (which I think that is American time...) to my timezone?

I am not sure if I was clear in this thread...

Waiting for all the suggestions,
pipesportugal
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2  
Old 11-27-2007, 11:28 PM
navaldesign's Avatar
General & Forum Moderator
 
Join Date: Oct 2005
Location: Italy
Posts: 9,346
Default Re: VH timezone server-mySQL function now()

You have to do it in your scripts: place a

putenv("TZ=Europe/Rome"); // Change to whatever your timezone is

comand in your php scripts (or in your local or config file), in the first lines.
__________________
Navaldesign
Logger Lite: Low Cost, Customizable, multifeatured Login script
Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old 11-27-2007, 11:56 PM
pipesportugal's Avatar
Second Lieutenant
 
Join Date: Jul 2007
Location: Oporto - Portugal
Posts: 101
Default Re: VH timezone server-mySQL function now()

Hello navaldesign,

In my case I imagine I should put instead:

putenv("TZ=Europe/Lisbon");

right ? I'll try it right away,

Thanks for Your so fast reply.
pipesportugal
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old 11-28-2007, 12:27 AM
pipesportugal's Avatar
Second Lieutenant
 
Join Date: Jul 2007
Location: Oporto - Portugal
Posts: 101
Default Re: VH timezone server-mySQL function now()

Hi navaldesign,

Nope, the /Lisbon doesn't solve it and neither does the /London and neither does a /gmt.

Any ideas ?

Thanks in advance,
pipesportugal
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old 11-28-2007, 10:12 AM
navaldesign's Avatar
General & Forum Moderator
 
Join Date: Oct 2005
Location: Italy
Posts: 9,346
Default Re: VH timezone server-mySQL function now()

It is, in fact, Europe/Lisbon . If it doesn't work, can ONLY be because you did not place it in the correct position.

Is now() defined by you ? or do you use smarty ?
otherwise you need to create a timestamp AFTER the envelope statement
__________________
Navaldesign
Logger Lite: Low Cost, Customizable, multifeatured Login script
Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old 11-28-2007, 11:15 PM
pipesportugal's Avatar
Second Lieutenant
 
Join Date: Jul 2007
Location: Oporto - Portugal
Posts: 101
Default Re: VH timezone server-mySQL function now()

Hello navaldesign,

The SQL sentence that I'm using is the following one:

mysql_query("UPDATE tabela_users SET dat2_users=now() WHERE email_users='$x_email_users'");

I am using this myQL function everytime the user logs into the reserved area so that I know his last login date and time and it works quite fine, except for the fact that the time is incorrect.

I have a config.php file placed at the begining of all php programs with the following line:
putenv ('TZ=Europe/London');
DOESN'T WORK.

I've also tried a suggestion from php.net online manual which was to use:
putenv ('TZ=Europe/London');
mktime(0,0,0,1,1,1970);
DOESN'T WORK.

I've placed the putenv ('TZ=Europe/London'); sentence just before the UPDATE sentence, just in case the information was not reaching there and...it DOESN'T WORK.

I must comment that this started to happen since I moved my mySQL database to VH, because it was working just fine in the old server.

Someone helps ?

pipesportugal
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old 11-28-2007, 11:41 PM
navaldesign's Avatar
General & Forum Moderator
 
Join Date: Oct 2005
Location: Italy
Posts: 9,346
Default Re: VH timezone server-mySQL function now()

Set the timezone for php, not for MySQL, then make a timestamp using php's time() (which, at this point, will be in your local time) and store the timestamp in the DB.

VH servers are in US, so that is logical if your old server was in CET zone.
__________________
Navaldesign
Logger Lite: Low Cost, Customizable, multifeatured Login script
Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old 11-29-2007, 02:33 AM
pipesportugal's Avatar
Second Lieutenant
 
Join Date: Jul 2007
Location: Oporto - Portugal
Posts: 101
Default Re: VH timezone server-mySQL function now()

Hi navaldesign, thanks for the help,

This did it for me:

GTM TIME:
setlocale(LC_TIME, 'en_UK');
$agora = gmstrftime("%Y-%m-%d %H:%M:%S",time());
mysql_query("UPDATE tabela_users SET dat2_users='$agora' WHERE email_users='$x_email_users'");

CET TIME
setlocale(LC_TIME, 'de_DE');
$agora = gmstrftime("%Y-%m-%d %H:%M:%S",time()+3600);

dat2_users is defined in the database as datetime variable.

pipesportugal
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT +1. The time now is 04:02 AM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC7
2005-2009 VodaHost Web Hosting Your Perfect Web Host - All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176