1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

PHP Date Help

Discussion in 'PHP' started by Pixel T., Jul 18, 2011.

  1. #1
    Hey,

    I have a Joomla project I'm working on and call the function "date" to get the current hour and minute. BUT, when I call the same function in the main directory of the project, the date is 8 hours off. Same function. Same call. Whats happening?

    I was thinking one may be the Joomla date, the other the server date but thats not it.

    Any ideas?

    Thanks,
     
    Pixel T., Jul 18, 2011 IP
  2. CrostE

    CrostE Peon

    Messages:
    30
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Is the server placed in another country? If not, you can try to use
    
    echo date_format($date, 'H:i:s');
    
    Code (markup):
     
    CrostE, Jul 19, 2011 IP
  3. Pixel T.

    Pixel T. Well-Known Member

    Messages:
    1,205
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    170
    #3
    I'll try this and let you know if it works. Thanks,
     
    Pixel T., Jul 19, 2011 IP
  4. suryawl

    suryawl Peon

    Messages:
    54
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    0
    #4
    i think the server in the different time zone
     
    suryawl, Jul 22, 2011 IP
  5. shaun.php1208

    shaun.php1208 Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi I agree with SURYAWL.

    That's also one of possibility to show diff time.
     
    shaun.php1208, Jul 23, 2011 IP
  6. ezprint2008

    ezprint2008 Well-Known Member

    Messages:
    611
    Likes Received:
    15
    Best Answers:
    2
    Trophy Points:
    140
    Digital Goods:
    1
    #6
    you might have to get the country and add or subtract the hours in the date code ..after you out out the hours, minutes seconds. break each down into $hour $minute etc

    ad do a standard +/- math on it to update it to your timestamp/date
    probablyhave to use an if or else statement to get the country and time and conversion

    exampl:
    if($position = "California";) {
    $time_update = $time_hour - 3;
    }
    elseif($position = "Iraq";) {
    $time_update = $time_hour + 8;
    etc

    Somebody has probably written a code for this by now as this would be a common problem encountered by International sites
     
    ezprint2008, Jul 25, 2011 IP
  7. bpasc95

    bpasc95 Active Member

    Messages:
    196
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    70
    #7
    It sounds like either a php.ini / environment override exists in one place and not in another -or- Joomla has date_default_timezone_set() set.

    -Bing
     
    bpasc95, Jul 26, 2011 IP
  8. sinha.sidhi

    sinha.sidhi Peon

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    simply define date function

    date(d/m/y)
     
    sinha.sidhi, Aug 29, 2011 IP