Php is a server-side language. And so this returns the time in the specified format.
What your looking for is javascript. You could solve this with this code:
function setTime() {
var d = new Date(),
el = document.getElementById("time");
el.innerHTML = formatAMPM(d);
setTimeout(setTime, 1000);
}
function formatAMPM(date) {
var hours = date.getHours(),
minutes = date.getMinutes(),
seconds = date.getSeconds(),
ampm = hours >= 12 ? 'pm' : 'am';
hours = hours % 12;
hours = hours ? hours : 12; // the hour '0' should be '12'
minutes = minutes < 10 ? '0'+minutes : minutes;
var strTime = hours + ':' + minutes + ':' + seconds + ' ' + ampm;
return strTime;
}
setTime();
I'm assuming your html looks likes this:
<p>
America/New_York
</p>
<p>
the time is <span id='time'></span>
</p>
Working Jsfiddle:
https://jsfiddle.net/z53byjcp/1/
Adapted AMPM function from this SO post:
How do you display javascript datetime in 12 hour AM/PM format?
Edit:
This is indeed local time.
I recommend you look into MomentJS for the timezones.
http://momentjs.com/timezone/