• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

Local Time in PHP

Reg Web

New Member
can anyone point me in the direction of somewhere where I would be able to get a php code to get the browser's time, not the server's time, on the page?
 
I prefer using PHP - I have more control.

I just need a code that won't give the following output:

Array
(
[0] => 24
[1] => 3
[2] => 19
[3] => 3
[4] => 3
[5] => 105
[6] => 0
[7] => 92
[9] => 1
)

Array
(
[tm_sec] => 24
[tm_min] => 3
[tm_hour] => 19
[tm_mday] => 3
[tm_mon] => 3
[tm_year] => 105
[tm_wday] => 0
[tm_yday] => 92
[tm_isdst] => 1
)
 
Due to the fact that PHP is parsed by the server, and the fact that PHP is made to be a server side language, this is impossible.

You'd need to use Javascript to accomplish this.
 
Or store variables inputted by the user as to what timezone he is in. This is what most scripts do.

Regards,
 
Why don't you make it in JavaScript?

<script LANGUAGE="javascript">
<!--
function startClock()
{
window.setInterval("Clock_Tick()",1000)
Clock_Tick()
}

function Clock_Tick()
{
var s=Date()
var t=s.substring(0,25)
document.getElementById("MyTime").innerHTML=t
document.all.MyTime.style.color="navy"
document.all.MyTime.style.fontFamily="verdana"
document.all.MyTime.style.fontSize="13"
document.all.MyTime.style.fontWeight="bold"
}
-->
</script>
 
Back
Top