Reputation: 21
I used this code to display the timezone and today's date in dd/mm/yyyy hh:mm
:
$timezone = date_default_timezone_get();
echo "The current server timezone is: " . $timezone . "<br/>";
$tod = date('m/d/Y h:m a');
echo $tod;
and I've set the timezone before so it displays the correct one, but every time I open the page in gives me 20/7/2019 1:07 pm, like the time never updates, I tried to change my server from wamp but still not updating.. anyone knows how can I solve it?
EDIT: I found out something that makes it more specific, it does update the hour, but the minute is stuck at 07, what would be the right way to make it behave right?
Upvotes: 0
Views: 200
Reputation: 21
Well, after re-checking the manual after specifying what the problem really is with, I found out that h:m is not right, because m
represents the month
not the minute, for minutes you have to put i
.
so if you want something like:
dd/mm/yyyy hh:mm am/pm
you should use:
$todays_date = date('d/m/Y h:i a');
note: many tutorials has it as h:m
, so always consider reading the manual: PHP: date - Manual
Upvotes: 1
Reputation: 1238
This is likely to have something to do with browser cache. Prepend your code with this:
header("cache-control: no-store, no-cache, must-revalidate, max-age=0");
And then clear your browser cache (this is important, otherwise, your new HTTP headers won't even reach the browser).
Upvotes: 0