-3

I need to add JavaScript variable to PHP array, my code is below and var date1 is JavaScript variable.

Code

$date1="2018-08-02";
$date=explode("-",$date1);

My JavaSript section is here

var date1=new Date(<?=$date[0].",".$date[1].",".$date[2]?>);
date1 place to index of array x
$incoming[$i] = array("x" =>+date1 , "y" => $total_inc);
$outgoing[$i] = array("x" => +date1, "y" => $total_out);

In this situation the value is return 0.

executable
  • 3,365
  • 6
  • 24
  • 52
sachu
  • 3
  • 1
  • 7

1 Answers1

0

You can't. JS code is executed after PHP finished executing own code. You can pass data from js to php by ajax or by setting a cookie.