www.webdeveloper.com
Results 1 to 3 of 3

Thread: [RESOLVED] Timestamp + Cookie - BST(British Summertime)

  1. #1
    Join Date
    Jun 2011
    Posts
    4

    resolved [RESOLVED] Timestamp + Cookie - BST(British Summertime)

    I'm on the next stage of my tutorial and I'm learning about timestamps and cookies.

    The tutorial gives me this code to store the cookie:

    Code:
    <?php
    //Calculate 60 days in the future
    //seconds * minutes * hours * days + current time
    $inTwoMonths = 60 * 60 * 24 * 60 + time(); 
    setcookie('lastVisit', date("G:i - m/d/y"), $inTwoMonths); 
    ?>
    To retrieve the cookie and create a response, I'm given this code:

    Code:
    <?php
    if(isset($_COOKIE['lastVisit']))
    	$visit = $_COOKIE['lastVisit']; 
    else
    	echo "You've got some stale cookies!";
    
    echo "Your last visit was - ". $visit;
    ?>
    The problem I am having is that it's currently BST here, not GMT and the server thinks it is 00:30, when in fact it is 01:30.

    I can't seem to figure out how to fix this.. any ideas how I can?

    Thanks in advance guys.
    ~RTriggerHappy

  2. #2
    Join Date
    May 2011
    Location
    With Hobbits
    Posts
    125
    Try this

    Code:
    <?php
    date_default_timezone_set('Europe/London');
    //Get more timezones at http://ch2.php.net/manual/en/timezones.php
    //Calculate 60 days in the future
    //seconds * minutes * hours * days + current time
    $inTwoMonths = 60 * 60 * 24 * 60 + time(); 
    setcookie('lastVisit', date("G:i - m/d/y"), $inTwoMonths); 
    ?>

    date_default_timezone_set('Europe/London');
    Should set any times or dates to your timezone, atleast if its in the head of your page it should.
    Albert Einstein ~ "Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction."

    Things To help you on this Site

    1. Place all php code in [php] Tags
    2. Place all html code in [html] Tags
    3. Remember to mark all your Threads Resolved using thead tools at the top when your problem is solved

  3. #3
    Join Date
    Jun 2011
    Posts
    4

    Thanks

    Thanks for the help again, you've been a real big help!

    ~RTriggerHappy

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
  •  
HTML5 Development Center



Recent Articles