SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist
    Join Date
    Mar 2001
    Location
    New York
    Posts
    502
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Return Date of Browser's PC not Server

    I want to place the current time and date to a user but using the date that is on the user's PC, not the server. I see a million examples using the server, others compensating for the time zone differences, etc. I know that this is simply accomplished with javascript but don't see anything regarding PHP. I'm going to have to do a little programming to return the date as:

    dayofweek, Month DD, YYYY - HH:MM AM/PM

    but I still need to know how to make this call! Anyone? Thanks in advance!
    My law forum and legal information website -- I also buy websites you may wish to sell

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well since PHP runs on the server it is impossible to grab the client's date from their computer. I do believe the only way would be to use javascript. I suppose you could use javascript to create a url with the client date and time but in order for PHP to get its hands on the date time supplied by javascript is through user intervnetion like a form submission or a link being pressed or possibly a javascript redirect.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Evangelist
    Join Date
    Mar 2001
    Location
    New York
    Posts
    502
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmmm.. yes... that's a good point!!!! I knew there had to be a reason... client side scripting sounds like the best idea. I'll just learn how to format the javascript and be done with it. PHP is more fun.
    My law forum and legal information website -- I also buy websites you may wish to sell

  4. #4
    The Hiding One lynlimz's Avatar
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    2,103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was actually figuring out a way to minimise user interaction. What you could do is have a page with only the javascript code to detect the user's date/time. (Not ideal though to get the seconds. *grin*)

    Then automatically redirect the user to the page he requested with the datetime already sent to the server.
    "Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
    -- Albert Einstein


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •