Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Oct 2005
    Location
    Surrey, England
    Posts
    286
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Javascript / PHP Date Function

    can anyone help with my problem. i need a script that can take the date and time from someones computer like javascript does but then implement it into a php shortcut e.g: $date_time;

    thanks in advance

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,640
    Thanks
    0
    Thanked 649 Times in 639 Posts
    You will need to use Javascript on page 1 to retrieve the date/time and then pass it as a search string to page 2 where PHP can then retiieve it.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    Regular Coder
    Join Date
    Oct 2005
    Location
    Surrey, England
    Posts
    286
    Thanks
    2
    Thanked 2 Times in 2 Posts
    could you please throw together a sample script for me then please?

  • #4
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    Quote Originally Posted by felgall
    You will need to use Javascript on page 1 to retrieve the date/time and then pass it as a search string to page 2 where PHP can then retiieve it.
    Alternatively, you could 'bounce' it off of a cookie and bypass the need for a handler page.

    i.e.
    Use js to create the cookie with the user's local time as the value, then immediately follow that by using PHP to read the cookie value and commit it to a PHP variable.
    All this can be done in the document head, so the PHP time variable is available anywhere in the construction of the page content.


  •  

    Posting Permissions

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