Let's say I have a page abc.php where the following PHP code lies.
<?php
$current_time = date("Y-m-d H:i:s",time());
$curtim=strtotime($current_time);
echo $current_time.' '.$curtim;
?>
This page simply prints the current time like 2015-07-27 14:18:18. And I get the correct time when I am working with a 'Do No Harm Attitude'.
When I close the tab and reopen it using a shortcut key- Ctlr+Shift+T after some time, i still get 2015-07-27 14:18:18 as current time. I guess the page is not getting reloaded using that short key.
Is there a way to fetch the current time correctly when such scenarios come??
If the problem is the page being cached some header should fix.
See here Making sure a web page is not cached, across all browsers
header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1.
header("Pragma: no-cache"); // HTTP 1.0.
header("Expires: 0"); // Proxies.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With