get Date and Time in php

Discussion in 'PHP' started by Kyriakos, Oct 1, 2009.

  1. #1
    hi,

    i have a web site in a server. this server has the time in GMT time zone. i want to display the time in GMT +2 hours. this is my PHP script for getting date and time.
    <?php print date("d/m/Y H:i:s")?>
    PHP:
    What i can do to get the "+2" hours?
     
    Kyriakos, Oct 1, 2009 IP
  2. pixmania

    pixmania Peon

    Messages:
    229
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You could try this...
    Open or create a .htaccess file and add the following line in it:
    SetEnv TZ Istanbul
    Code (markup):
    Istanbul is just a random country I selected, you could of course, select any GMT +2 country.
     
    pixmania, Oct 1, 2009 IP
  3. phpdoctor22

    phpdoctor22 Peon

    Messages:
    96
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    turn the date into a timestamp strtotime() then add 7200 to the time.
     
    phpdoctor22, Oct 1, 2009 IP
  4. dweebsonduty

    dweebsonduty Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    Digital Goods:
    1
    #4
    
    <?php
    $thetime = mktime(date("H")+2,date("i"),date("s"),date("m"),date("d"),date("Y"));
    echo date("d/m/Y H:i:s", $thetime);
    ?>
    
    PHP:
     
    dweebsonduty, Oct 1, 2009 IP