browser time [message #173261] |
Thu, 31 March 2011 19:57 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 #173272 is a reply to message #173271] |
Fri, 01 April 2011 03:13 |
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 |
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 #173282 is a reply to message #173272] |
Fri, 01 April 2011 10:41 |
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.
|
|
|