Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Php time adjustment problems

  • 07-09-2002 05:04PM
    #1
    Registered Users, Registered Users 2 Posts: 15,771 ✭✭✭✭


    Am trying to adjust the time reported on a site i'm currently working on and am running into difficulties.

    I've put the code below in which works fine for the current time (reported in $g_complete_date_format ) but $g_normal_date_format is used for recorded messages however the "time()" part of it is pulling the current time from the server not the recorded time.

    If i leave it as $g_normal_date_format = "d-m H:i" then its reporting the correct times ..bar the fact that they are 9 hours ahead of the current timezone here.
    Anyone got suggestions? , i've read over the stuff on sourceforge..but my brain seems to have gone to mush today and cannot figure it out :(

    CURRENT INCORRECT CODE :(

    $hourdiff = "-9"; // hours difference between server time and local time
    $timeadjust = ($hourdiff * 60 * 60);
    $g_short_date_format = "d-m";
    $g_normal_date_format = date("d-m H:i",time() + $timeadjust); <<<<<<<
    the time() is incorrect !!
    $g_complete_date_format = date("d-m Y H:i",time() + $timeadjust);

    Thanks.

    <edit>didn't see there was a php forum now, mods, sorry for posting in the wrong place, please move</edit>

    Have a weather station?, why not join the Ireland Weather Network - http://irelandweather.eu/



Comments

  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    Works fine for me. Try putting paranthesis around the time adjustment:

    date("d-m H:i", (time() + $timeadjust));

    adam


Advertisement