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.

Detecting user's local machine time

Discussion in 'Programming' started by dollarearner, Mar 16, 2013.

  1. #1
    Hello,
    Here is what im looking for, when a user opens my webpage, the script should detect the local time of a user's machine and save it to database or text file in my website. Some says that it is possible using javascript and php, but im weak in coding, could anyone pls help....

    thanx in advance.
    Last edited: Mar 16, 2013
    dollarearner, Mar 16, 2013 IP
  2. robzdc

    robzdc Greenhorn

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    11
    #2
    You get the time with Javascript first
    Code (Text):
    1. now = new Date();
    Then send an Ajax post
    Code (Text):
    1. $.post('save.php',{time: now, ip : ip},function(){
    2.  
    3. }
    I dont really know how you are going to know which user is but, thats an example
    robzdc, Mar 16, 2013 IP
  3. dollarearner

    dollarearner Active Member

    Messages:
    233
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    hey robzdc,
    thanks.... i think cookies could be used to detect the user, wouldn't that work?
    it would be helpful if anyone could post here full source code.
    dollarearner, Mar 16, 2013 IP
  4. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,883
    Likes Received:
    33
    Best Answers:
    51
    Trophy Points:
    100
    #4
    Cookies are used by the server to save data on the user's computer. What you want is to save the user's time (or timezone?) on the server. That's done the way robzdc showed you. The complete code? That would depend on your current PHP code. What you're asking for is like a custom-fit shirt - we have to know your measurements first.
    Rukbat, Mar 17, 2013 IP
  5. dollarearner

    dollarearner Active Member

    Messages:
    233
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #5
    hello Rukbat,
    yes, you are right, but im not looking for a custom-fit-shirt as you mentioned, sorry i did not mention that in my previous post, i hope i can make it work in my websites doing some code modifications to detect the exact user. Examples of what im looking for can be found here - http://stackoverflow.com/questions/13/determining-a-web-users-time-zone , but they dont work. Hope you got my point.

    thanks
    dollarearner, Mar 17, 2013 IP
  6. kutchbhi

    kutchbhi Member

    Messages:
    100
    Likes Received:
    3
    Best Answers:
    2
    Trophy Points:
    45
    #6
    dollarearner - the stackoveflow link you posted explains how to do things perfectly. Show us what you tried and someone will be able to point out why it didn't work.
    kutchbhi, Mar 29, 2013 IP