Most efficient way to determine the users time?

Discussion in 'PHP' started by kingjacob, Oct 15, 2007.

  1. #1
    I am wanting to code a WP plugin myself using php that will display a different picture depending on the time of day of a visitor. What would be the most efficient way to determine the time of the user?
     
    kingjacob, Oct 15, 2007 IP
  2. phper

    phper Active Member

    Messages:
    247
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #2
    1. Translate user's IP address to user's location
    2. Get the time difference between that location and the web server
    3. Add / subtract server's current time with the difference

    Note though that you still can't get 100% accuracy in translating IP address to location. Check maxmind.com for a sample solution (or search for 'ip to location' with your preferred search engine).
     
    phper, Oct 15, 2007 IP
  3. Jeff Blake

    Jeff Blake Peon

    Messages:
    32
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You will probably want to use Javascript because it's a client-side language to pull the client's date/time, and then feed that into your PHP script.
     
    Jeff Blake, Oct 15, 2007 IP