php user time

Discussion in 'PHP' started by dizyn, Mar 10, 2009.

  1. #1
    Hi

    I want to find current time of user area, for example a users is in Islamabad how can find its local time? at the same time other user is in London. This is possible in js

    Can we do it with php? if so can you please tell me how I can do this?
     
    dizyn, Mar 10, 2009 IP
  2. nabil_kadimi

    nabil_kadimi Well-Known Member

    Messages:
    1,065
    Likes Received:
    69
    Best Answers:
    0
    Trophy Points:
    195
    #2
    You can know the user time with PHP alone, but you can know his country, therefore his timezone.
     
    nabil_kadimi, Mar 10, 2009 IP
  3. xlcho

    xlcho Guest

    Messages:
    532
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #3
    As you said it is possible in JS, cause it's client side. You can't do that with php, cause it's executed on the server and you can get only your server's date and time.
     
    xlcho, Mar 10, 2009 IP
  4. LincolnAve

    LincolnAve Peon

    Messages:
    213
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    What you will need to do is get the ip address of the client. Then convert the IP to city location (or Lon & Lat) then look up the timezone. I did it, try searching google for the software needed. It took me a few days to get it the way I wanted it (displaying businesses near the user), but it works very well.

    You must remeber that this is not an exact science since some IPs are where they are supposed to be.

    Good Luck!!
     
    LincolnAve, Mar 10, 2009 IP