how to make datetime (server time + 6 hours)?

Discussion in 'PHP' started by cri8bat, Nov 26, 2010.

  1. #1
    Hi all,

    I have datatime on my database, and it stores the server date time. However the website is targeted for UK users and I want the datetime to be changed for uk time, therefore + 6hrs.

    how the hell I do this?
     
    cri8bat, Nov 26, 2010 IP
  2. ActiveFrost

    ActiveFrost Notable Member

    Messages:
    2,072
    Likes Received:
    63
    Best Answers:
    3
    Trophy Points:
    245
  3. cri8bat

    cri8bat Well-Known Member

    Messages:
    1,459
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    160
    #3
    cri8bat, Nov 26, 2010 IP
  4. ActiveFrost

    ActiveFrost Notable Member

    Messages:
    2,072
    Likes Received:
    63
    Best Answers:
    3
    Trophy Points:
    245
    #4
    You shouldn't be asking questions here then .. go and outsource this ( Buy, Sell and Trade section ).
     
    ActiveFrost, Nov 26, 2010 IP
  5. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #5
    Might work depends on how your adding date/time, open your .htaccess file or create one and add the following line:
    SetEnv TZ Europe/London
    Code (markup):
     
    MyVodaFone, Nov 26, 2010 IP
  6. tvoodoo

    tvoodoo Active Member

    Messages:
    239
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    53
    #6
    You can also use the php function : date_default_timezone_set();
    look it up...
     
    tvoodoo, Nov 29, 2010 IP
  7. drctaccess

    drctaccess Peon

    Messages:
    62
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    0
    #7
    You better use this:
    ini_set('date.timezone', 'Europe/London');
    instead of
    date_default_timezone_set('Europe/London');

    because of this:

    Since PHP 5.1.0 (when the date/time functions were rewritten), every call to a date/time function will generate a E_NOTICE if the timezone isn't valid, and/or a E_WARNING message if using the system settings or the TZ environment variable.
     
    drctaccess, Nov 29, 2010 IP
  8. Hannaspice

    Hannaspice Active Member

    Messages:
    77
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #8
    $time06 = time() +3600*6;
    $datum = date("Y-m-d H:i:s",$time06);
    Code (markup):
    I hope his help.
     
    Hannaspice, Jan 25, 2011 IP
  9. koula

    koula Peon

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Convert your time into seconds and adding extra time in seconds also , when you finish convert again new time into format you want.
     
    koula, Feb 3, 2011 IP
  10. srisen2

    srisen2 Peon

    Messages:
    359
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #10
    you may want to consider just displaying the date or displaying the time as 5 minutes ago or 1 hour ago or 3 days ago, this seems to be the accepted solution for time zones issues when trying to display your date time to users in different time zones
     
    srisen2, Feb 3, 2011 IP
  11. G3n3s!s

    G3n3s!s Active Member

    Messages:
    325
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    80
    #11
    $yourtime = time() + 60*60*6;

    enjoy :p
     
    G3n3s!s, Feb 4, 2011 IP