Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/265875-php-interact-with-javascript/
Share on other sites

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

  • 3 weeks later...

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...


?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.