Results 1 to 8 of 8

Thread: VH timezone server-mySQL function now()
      
   

  1. #1
    pipesportugal's Avatar
    pipesportugal is offline Second Lieutenant
    Join Date
    Jul 2007
    Location
    Oporto - Portugal
    Posts
    129

    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

  2. #2
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,115

    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!


  3. #3
    pipesportugal's Avatar
    pipesportugal is offline Second Lieutenant
    Join Date
    Jul 2007
    Location
    Oporto - Portugal
    Posts
    129

    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

  4. #4
    pipesportugal's Avatar
    pipesportugal is offline Second Lieutenant
    Join Date
    Jul 2007
    Location
    Oporto - Portugal
    Posts
    129

    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

  5. #5
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,115

    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!


  6. #6
    pipesportugal's Avatar
    pipesportugal is offline Second Lieutenant
    Join Date
    Jul 2007
    Location
    Oporto - Portugal
    Posts
    129

    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

  7. #7
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,115

    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!


  8. #8
    pipesportugal's Avatar
    pipesportugal is offline Second Lieutenant
    Join Date
    Jul 2007
    Location
    Oporto - Portugal
    Posts
    129

    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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

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