Skip to content

Instantly share code, notes, and snippets.

@camt
Created January 31, 2012 00:18
Show Gist options
  • Save camt/1707749 to your computer and use it in GitHub Desktop.
Save camt/1707749 to your computer and use it in GitHub Desktop.
Client-side time with PHP and JS
if(!$_REQUEST["client_time"])
{
$vars = "?";
foreach($_REQUEST as $key => $val) {
$vars .= $key."=".$val."&";
}
echo "<script type=\"text/javascript\">";
echo "localtime = new Date();";
echo "document.location.href = '".$PHP_SELF.$vars."client_time='
+ localtime.getTime();";
echo "</script>";
}
else
{
// Process page as normal
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment