Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Your Update2 isn't going to work at all.</p> <p>Even though the javascript comes before the php, it's not executed before. It's not even executed on the same machine!</p> <p>PHP treats that javascript block just like plain text; it just sends it to the browser as-is.</p> <p>So PHP sees your code as:</p> <pre><code>&lt;?php ?&gt; A bunch of stuff I don't care about &lt;?php echo $_COOKIE['something which doesnt exist']; ?&gt; </code></pre> <p>It seems that you are using cURL to scrape a chat site, right? You're not trying to code the site?</p> <p>If that's the case, then this is all the php code you need:</p> <pre><code>$ms=time(); </code></pre> <p>And then just use that in your curl setopts.</p> <p>Except that won't work, because the javascript is doing some wacky stuff with the time. For example, it's multiplying the number of hours by 24 * 60 *1000 to get milliseconds, I assume, but that's wrong.</p> <p>As I'm typing this, it's 9:42am local time. 9 hours is 9 * 60 * 60 * 1000 = 32,400,000ms.</p> <p>(9 hours * 60 minutes per hour * 60 seconds per minute * 1000 ms per second)</p> <p>If you're in charge of this javascript, you should probably fix it to create a proper timestamp to avoid these headaches :)</p> <p>But in the spirit of answering the question as presented, this php code will duplicate the (broken) time math in the javascript:</p> <pre><code>$ms = round(date('h',$sec)*24*60*1000 + date('i',$sec)*60*1000 + date('s',$sec)*1000+$usec*1000); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload