Results 1 to 7 of 7

Thread: Easy way to adjust server time with script?

  1. #1
    Join Date
    Jun 2005
    Posts
    15

    Default Easy way to adjust server time with script?

    I'm trying to adjust the server time (which is set to GMT) with my form code, derived fields, etc., so that the form submission ends up sending my form with a time stamp of GMT -4 hours, or EST. Not being too handy with php, I've nonetheless tried incorporating the following snippet in my form code... to no avail...

    <?
    putenv("TZ=US/Eastern");
    date("h:i:s")."\n";
    ?>

    The derived fields always default back to the GMT server time and so GMT is the time that gets stamped. I'm sure there is an easy fix to this problem, but as a php novice, I'm stumped. Couldn't find an answer here on the forum. Is there a place in the script that I can compensate and subtract 4 hours or force "TZ=US/Eastern" or use some other method?

    Thanks.

  2. #2
    Join Date
    Dec 2003
    Posts
    3,980

    Default Re: Easy way to adjust server time with script?

    Hi,

    The date you're seeing is on the email, right? Or do you mean a value being placed in a field?

    If it's the email, then there's nothing you can do without changing the server environment.

    If it's in a field that FormMail is deriving, then there is probably something that can be done.
    Russell Robinson - Author of Tectite FormMail and FormMailDecoder
    http://www.tectite.com/

  3. #3
    Join Date
    Jun 2005
    Posts
    15

    Default Re: Easy way to adjust server time with script?

    No, I'm not talking about the date of the e-mail. I'm talking about putting a hidden "Time" field on the form and instead of sending it in UTC (my server's time zone), I want it to be in EST (or -4 hours). It's easy to have a hidden Time field in the server's time zone using derived fields, but I don't see a way to subtract 4 hours from the server time using the derived fields or some other php script to make this field show the time in EST when I receive the form data via e-mail. I can write the time in EST to the page that has the form BEFORE submitting the form, but once the form gets sent, it sends the form with the server's time (UTC) in that field. I need the field in EST on the receiving end.

    Hope that clarifies what I'm trying to do a bit more.

    Thanks!

  4. #4
    Join Date
    Dec 2003
    Posts
    3,980

    Default Re: Easy way to adjust server time with script?

    Hi,

    So, if you have this derived field:
    Code:
    <input type="hidden" name="derive_fields" value="tz = %tz%" />
    then "tz" gets zero (e.g. +0). Is that correct?

    This definitely means that your server is running with a timezone of GMT, as you already said.

    If you've got a shared host, then there's probably not much you can do to the server.

    However, if you have a VPS/VDS or similar, you can generally set the system timezone to what you want. This is an environment thing, so it doesn't involve changing the "hardware clock".

    This is the best solution - the server owner's timezone is what the server software runs in. That's certainly what we do here.

    But, if you can't do that then try adding the following to the top of FormMail:

    PHP Code:
    <?
    putenv
    ("PHP_TZ=US/Eastern");
    ?>
    You tried "TZ", but I think the correct setting for PHP might be PHP_TZ.

    If that doesn't work, look for these lines in FormMail:
    PHP Code:
     //
     // Capture the current date and time, for various purposes.
     //
    $lNow time(); 
    Try this:
    PHP Code:
     //
     // Capture the current date and time, for various purposes.
     //
    $lNow time();
    $lNow -= 4*3600;  // adjust to my time 
    This is definitely not the ideal solution, but you may have to use it.
    Russell Robinson - Author of Tectite FormMail and FormMailDecoder
    http://www.tectite.com/

  5. #5
    Join Date
    Jun 2005
    Posts
    15

    Default Re: Easy way to adjust server time with script?

    Bingo!

    I hadn't tried putting the following on top of your script.
    So that's where it belongs!!! I had been trying to manipulate my hidden "time" field value in the form itself.

    Works great just like this... (Didn't work as "PHP_TZ=US/Eastern" however.)

    <?
    putenv("TZ=US/Eastern");
    ?>

    and then this in the form...

    <input type="hidden" name="derive_fields" value="Time=%hour12%.%':'%.%min% + %AMPM%">


    Simple... Thanks very much!

  6. #6
    Join Date
    Sep 2005
    Posts
    9

    Default Re: Easy way to adjust server time with script?

    I have the same issue but when I add the lines;

    <?
    putenv("TZ=US/Eastern");
    ?>

    to the formmail.php script.. I get a parse error. Is this supposed to be added to my form page or the formmail.php script?

    Thanks.

  7. #7
    Join Date
    Jun 2005
    Posts
    15

    Default Re: Easy way to adjust server time with script?

    Hi. Me again.

    Put it at the very, very top of the formmail.php script, as in:

    <?
    putenv("TZ=US/Eastern");
    ?>
    <?php
    $FM_VERS = "6.02"; // script version

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Script Works, Email Contains No Information
    By JakeForest in forum FormMail Subscription Support
    Replies: 10
    Last Post: 28-Dec-2005, 10:51 PM
  2. Thanks for the great script, but I am having issues...
    By darknightjedi in forum FormMail Subscription Support
    Replies: 12
    Last Post: 26-Aug-2004, 08:08 PM
  3. FormMail Script Error Message
    By rose in forum FormMail Subscription Support
    Replies: 2
    Last Post: 27-Jun-2004, 04:59 AM
  4. DEF_ALERT setup in script - Don't understand
    By jodmcc in forum FormMail Subscription Support
    Replies: 2
    Last Post: 17-Jun-2004, 07:02 AM
  5. Great script but.....
    By Remosz in forum FormMail Subscription Support
    Replies: 3
    Last Post: 23-Mar-2004, 10:47 PM

Bookmarks

Posting Permissions

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