0

Possible Duplicate:
Access a JavaScript variable from PHP

Let's say I have the following javascript:

<script>
    var today = new Date();
    var dd = today.getDate();
    var mm = today.getMonth()+1; //January is 0!

    var yyyy = today.getFullYear();
    if(dd<10){dd='0'+dd} if(mm<10){mm='0'+mm} today = mm+'/'+dd+'/'+yyyy;
</script>

Now I want to get the value of today variable into PHP.

$cur_date = '<script type="text/javascript"> document.write(today) </script>';

echo "current date: $cur_date";

$checkin = strtotime($cur_date);

Although I can output the current date but how can I transfer it to $checkin variable with strtotime function?

Community
  • 1
  • 1
jaypabs
  • 1,519
  • 10
  • 43
  • 62
  • or this http://stackoverflow.com/questions/11029298/passing-a-javascript-value-to-a-php-variable-with-limitation – peroija Nov 08 '12 at 02:30

1 Answers1

2

PHP runs before the page is sent to the browser. It is impossible in the way you want to do it.

epascarello
  • 204,599
  • 20
  • 195
  • 236