Suppose I'm running the following JavaScript getTime() function
<script language="JavaScript">
var $x = Math.round((new Date()).getTime()/1000);
</script>
What would the equivalent code in PHP look like?
<?php
$x = time(); // seconds
$x = microtime(); // milliseconds
?>
Check out time() and microtime().
$time_stamp = time();
echo $time_stamp;
Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).
( (string)time() ) . ( (string)intval(microtime()*1000) )and yes all the parentheses are necessary, otherwise it drops a digit.