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?
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?
Try something like this:
echo number_format(microtime(true)*1000,0,'.','');
or because you are dividing by 1000, most probably you need this:
echo number_format(microtime(true),0,'.','');
<?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).
You'd use the php function time(). It creates the timestamp for you.
<?php
$time = time();
?>