![]() |
|
| |||||||
| Notices |
| mySQL & PHP Discussions, information and help with mySQL and PHP. |
![]() |
| | LinkBack | Thread Tools |
|
#1
| ||||
| ||||
|
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 |
|
#2
| ||||
| ||||
|
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! |
|
#3
| ||||
| ||||
|
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 |
|
#4
| ||||
| ||||
|
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 |
|
#5
| ||||
| ||||
|
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! |
|
#6
| ||||
| ||||
|
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 |
|
#7
| ||||
| ||||
|
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! |
|
#8
| ||||
| ||||
|
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 |