Created
January 31, 2012 00:18
-
-
Save camt/1707749 to your computer and use it in GitHub Desktop.
Client-side time with PHP and JS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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