How to save user GMT time and comapare it with server time.

Discussion in 'PHP' started by mak1084, Jan 7, 2009.

  1. #1
    hi,
    I want my users to put there GMT time while registration so that I can do some manipulation over it.
    But my problem after getting the GMT of a user how I'll get the time of that user's GMT. is there any way to compare the two GMT and get the actual time.
    here you know GMT of both user and server and server time. now we need to calculate users time.
    how to do this
    please help.
     
    mak1084, Jan 7, 2009 IP
  2. manjifera

    manjifera Well-Known Member

    Messages:
    232
    Likes Received:
    4
    Best Answers:
    1
    Trophy Points:
    118
  3. mak1084

    mak1084 Active Member

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    51
    #3
    it can be done in javascript but I wanna put the GMT value in and compare it in server side.
     
    mak1084, Jan 7, 2009 IP
  4. manjifera

    manjifera Well-Known Member

    Messages:
    232
    Likes Received:
    4
    Best Answers:
    1
    Trophy Points:
    118
    #4
    you can get user time and gmt zone using this

    <input name="time" id="time" type="text">
    <script language="javascript" type="text/javascript">
    
    var curdate = new Date()
    document.getElementById("time").value = curdate;
    </script>
    HTML:
    get this data with form submit, n do precess. as per your needs!
     
    manjifera, Jan 8, 2009 IP
  5. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #5
    You cannot get the user's time using solely PHP, the most accurate you could get would be an IP Lookup or reading the headers sent by the browser (but AFAIK no mainstream browser sends details about the time of the computer...)

    Just give them a Timezone option... :)
     
    Danltn, Jan 8, 2009 IP
  6. mak1084

    mak1084 Active Member

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    51
    #6
    @Danltn hey thanks. So now If I give the option to user and take there GMT now how I'll calculate there time only with there GMT??
     
    mak1084, Jan 9, 2009 IP