FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » browser time
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
browser time [message #173261] Thu, 31 March 2011 19:57 Go to next message
suresh is currently offline  suresh
Messages: 5
Registered: March 2011
Karma: 0
Junior Member
Hi
How to get browser time (clients time)? I used localtime() and it gives the server time only and not the client time.
thanks
suresh
Re: browser time [message #173262 is a reply to message #173261] Thu, 31 March 2011 20:09 Go to previous messageGo to next message
Luuk is currently offline  Luuk
Messages: 329
Registered: September 2010
Karma: 0
Senior Member
On 31-03-2011 21:57, suresh wrote:
> Hi
> How to get browser time (clients time)? I used localtime() and it gives the server time only and not the client time.
> thanks
> suresh

PHP is evaluated on the server.

If you want to get the browser time than you should send it to your
server via GET, POST, any other way you are able to send data from your
client to the server.....

--
Luuk
Re: browser time [message #173263 is a reply to message #173261] Thu, 31 March 2011 20:16 Go to previous messageGo to next message
Michael Fesser is currently offline  Michael Fesser
Messages: 215
Registered: September 2010
Karma: 0
Senior Member
.oO(suresh)

> How to get browser time (clients time)? I used localtime() and it gives
> the server time only and not the client time.

You would have to use JavaScript and have it send the client's time to
your server in another HTTP request.

May I ask why you need the client's time/timezone?

Micha
Re: browser time [message #173264 is a reply to message #173263] Thu, 31 March 2011 21:08 Go to previous messageGo to next message
suresh is currently offline  suresh
Messages: 5
Registered: March 2011
Karma: 0
Junior Member
thanks for the replies.

I just wanted to write a greeting in my web page based on the local client time...like Good Morning/Afternoon/Evening...But I have no clue about javascript and let me see what to do now...

suresh
Re: browser time [message #173265 is a reply to message #173264] Thu, 31 March 2011 21:16 Go to previous messageGo to next message
Michael Fesser is currently offline  Michael Fesser
Messages: 215
Registered: September 2010
Karma: 0
Senior Member
.oO(suresh)

> thanks for the replies.
>
> I just wanted to write a greeting in my web page based on the local
> client time...like Good Morning/Afternoon/Evening...But I have no clue
> about javascript and let me see what to do now...

Offtopic: It seems to be quite common these days and is IMHO a severe
bug in Google's web interface to the Usenet groups - the missing
References header. This makes following a thread quite complicated,
because the postings without that header usually appear completely out
of order and out of context.

Any chance to change that or use a real newsreader like Forté Agent or
Thunderbird for posting to newsgroups? Google Groups just sucks.

Micha
Re: browser time [message #173266 is a reply to message #173264] Thu, 31 March 2011 21:32 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
suresh wrote:
> thanks for the replies.
>
> I just wanted to write a greeting in my web page based on the local client time...like Good Morning/Afternoon/Evening...But I have no clue about javascript and let me see what to do now...
>

Oh ok..

Send the GMT to the client, and write a little bit of script to turn it
into local time, and pop it in to an empty div..

getTimeOffset() returns the number of *minutes* between browser time and
GMT.

According to my javascript manual..


> suresh
Re: browser time [message #173267 is a reply to message #173266] Thu, 31 March 2011 21:50 Go to previous messageGo to next message
suresh is currently offline  suresh
Messages: 5
Registered: March 2011
Karma: 0
Junior Member
hey since i am newbie, i didnt understand what you suggested. can you give me a sample code?
thanks
suresh
Re: browser time [message #173268 is a reply to message #173267] Thu, 31 March 2011 22:52 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
suresh wrote:
> hey since i am newbie, i didnt understand what you suggested. can you give me a sample code?
> thanks
> suresh
not really. I am no JavaScript genius.

Try in the JavaScript forum

I just know enough t know that way would most likely work: Not how to
write it.
Re: browser time [message #173269 is a reply to message #173268] Fri, 01 April 2011 00:22 Go to previous messageGo to next message
P E Schoen is currently offline  P E Schoen
Messages: 86
Registered: January 2011
Karma: 0
Member
"The Natural Philosopher" wrote in message
news:in30j3$pr2$1(at)news(dot)albasani(dot)net...

> Try in the JavaScript forum

> I just know enough t know that way would most likely work: Not
> how to write it.

Here is a simple demo:
www.muttleydog.com/JavaScriptDateTimeDemo.htm

I found the basics of how to do this and other things here:
http://www.linuxtopia.org/online_books/javascript_guides/javascript_faq/ind ex.htm

Paul
Re: browser time [message #173270 is a reply to message #173269] Fri, 01 April 2011 00:59 Go to previous messageGo to next message
suresh is currently offline  suresh
Messages: 5
Registered: March 2011
Karma: 0
Junior Member
Hi Paul,
thanks, why dont you paste your code also here ? :)
suresh
Re: browser time [message #173271 is a reply to message #173269] Fri, 01 April 2011 01:14 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
P E Schoen wrote:
> "The Natural Philosopher" wrote in message
> news:in30j3$pr2$1(at)news(dot)albasani(dot)net...
>
>> Try in the JavaScript forum
>
>> I just know enough t know that way would most likely work: Not
>> how to write it.
>
> Here is a simple demo:
> www.muttleydog.com/JavaScriptDateTimeDemo.htm
>
> I found the basics of how to do this and other things here:
> http://www.linuxtopia.org/online_books/javascript_guides/javascript_faq/ind ex.htm
>
>
> Paul
shame none of em seem to work in firefox 4..
Re: browser time [message #173272 is a reply to message #173271] Fri, 01 April 2011 03:13 Go to previous messageGo to next message
P E Schoen is currently offline  P E Schoen
Messages: 86
Registered: January 2011
Karma: 0
Member
"The Natural Philosopher" wrote in message
news:in38ug$8k4$1(at)news(dot)albasani(dot)net...

> shame none of em seem to work in firefox 4..

OK. I fixed it (my demo anyway). Firefox is much more strict than IE8.

www.muttleydog.com/JavaScriptDateTimeDemo.htm

I had to use document.forms.Form1.Time.value

Paul
Re: browser time [message #173274 is a reply to message #173270] Fri, 01 April 2011 04:05 Go to previous messageGo to next message
P E Schoen is currently offline  P E Schoen
Messages: 86
Registered: January 2011
Karma: 0
Member
"suresh" wrote in message
news:ef82c644-ec3a-41f0-9134-57fbb2560557(at)glegroupsg2000goo(dot)googlegroups(dot)co m...

> Hi Paul,
> thanks, why dont you paste your code also here ? :)

You can just use your browser and View | Source. But the script is as
follows:

function sbClock() {
var DateString=(new Date()).toString();
document.forms.Form1.Time.value=
DateString.substr( DateString.indexOf(":")-2, 8 );
}

I got that from the FAQ:
http://www.linuxtopia.org/online_books/javascript_guides/javascript_faq/clo ckexa.htm

But the substring is incorrect. Apparently there are many other errors, so
it should be used with caution. A better JavaScript reference is:
http://jibbering.com/faq/

Paul
Re: browser time [message #173280 is a reply to message #173267] Fri, 01 April 2011 07:59 Go to previous messageGo to next message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma: 0
Senior Member
El 31/03/2011 23:50, suresh escribió/wrote:
> hey since i am newbie, i didnt understand what you suggested. can you give me a sample code?
> thanks
> suresh

If you want to post a reply using the Google site, you need to click on
the "Reply" link below the message you want to reply to. If you click on
"New entry" you are opening a new thread. You've already opened four
different threads for this same question!

http://img535.imageshack.us/img535/7697/browsertime.png



--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
Re: browser time [message #173282 is a reply to message #173272] Fri, 01 April 2011 10:41 Go to previous message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
P E Schoen wrote:
> "The Natural Philosopher" wrote in message
> news:in38ug$8k4$1(at)news(dot)albasani(dot)net...
>
>> shame none of em seem to work in firefox 4..
>
> OK. I fixed it (my demo anyway). Firefox is much more strict than IE8.
>
> www.muttleydog.com/JavaScriptDateTimeDemo.htm
>
> I had to use document.forms.Form1.Time.value
>
> Paul
>
yeah..that sounds right and now works right.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: mssql_select_db problem
Next Topic: relative v. absolute paths
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Oct 06 18:25:12 GMT 2024

Total time taken to generate the page: 0.02714 seconds