marcus_epik Posted July 18, 2012 Share Posted July 18, 2012 Hi, so i want to make java script get the client date and then pass it on to php so that it can upload it to the database but i have no idea how to go about doing this and was wondering if any of you could help or give me an idea about how to go about doing this. Thanks, Marcus Quote Link to comment https://forums.phpfreaks.com/topic/265875-php-interact-with-javascript/ Share on other sites More sharing options...
alexmark Posted July 18, 2012 Share Posted July 18, 2012 There are several useful methods in JavaScript?s Date object (e.g. Date.getTimezoneOffset(), Date.toLocaleString()) You would then have to save teh information retreaved to the db. Quote Link to comment https://forums.phpfreaks.com/topic/265875-php-interact-with-javascript/#findComment-1362347 Share on other sites More sharing options...
marcus_epik Posted July 18, 2012 Author Share Posted July 18, 2012 There are several useful methods in JavaScript?s Date object (e.g. Date.getTimezoneOffset(), Date.toLocaleString()) You would then have to save teh information retreaved to the db. ok, that is a good start, would anybody have any idea how to get the date into a php variable thanks, Marcus Quote Link to comment https://forums.phpfreaks.com/topic/265875-php-interact-with-javascript/#findComment-1362422 Share on other sites More sharing options...
ScotDiddle Posted August 8, 2012 Share Posted August 8, 2012 marcus_epik, I would use jQuery AJAX, but here is a "Quick and Dirty" that should work... Scot L. Diddle, Richmond VA <script> parmPassedToPHP = new Image(); function getUsersScreenResolution(incomingVar) { var passedParm = incomingVar; // alert('Hi Mom'); var result; var at = '@'; var tilde = '~'; var param1A = screen.width; var param1B = 'W'; var param2A = screen.height; var param2B = 'H'; var phpVariable = param1A + at + param1B + tilde + param2A + at + param2B; iURL="transferJSParamToPHP.php?variable=" + phpVariable; result = parmPassedToPHP.src=iURL; // alert(result); }; </script> Where : transferJSParamToPHP.php looks like this... <?php $getVariable = $_GET['variable']; // Copy $getVariable to DB... ?> Quote Link to comment https://forums.phpfreaks.com/topic/265875-php-interact-with-javascript/#findComment-1367906 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.