What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » JavaScript Localtime

Pages: (2): « First [ 1 ] 2 » Last »
JavaScript Localtime
Author: Message:
Eddie
Veteran Member
*****


Posts: 2078
Reputation: 30
33 / Male / Flag
Joined: Oct 2005
Status: Away
O.P. JavaScript Localtime
ok i did  a google search, and found something but it didnt work, and you all seem to be php whizzes so...

im looking for some php that posts the users local time onto my website, instead of the databases local time :) if thats possible in php ty :)

EDIT: Title Changed to JavaScript Local Time, Read my latest post :)

This post was edited on 04-11-2007 at 02:24 PM by Eddie.
...there used to be a signature here :)
04-11-2007 01:42 PM
Profile PM Web Find Quote Report
Ezra
Veteran Member
*****

Avatar
Forgiveness is between them and God

Posts: 1960
Reputation: 31
37 / Male / Flag
Joined: Mar 2003
RE: PHP Localtime
You don't know the users local time unless they tell you and you store it in a database.

EDIT: It's possible however with Javascript.

This post was edited on 04-11-2007 at 01:51 PM by Ezra.
[Image: 1-0.png]
             
04-11-2007 01:49 PM
Profile PM Web Find Quote Report
Eddie
Veteran Member
*****


Posts: 2078
Reputation: 30
33 / Male / Flag
Joined: Oct 2005
Status: Away
O.P. RE: PHP Localtime
quote:
Originally posted by Ezra
You don't know the users local time unless they tell you and you store it in a database.
A PHP Script i found did it via javascript / php it just failed :(

http://www.mtdev.com/2002/07/display-local-time/
...there used to be a signature here :)
04-11-2007 01:51 PM
Profile PM Web Find Quote Report
absorbation
Elite Member
*****

Avatar

Posts: 3636
Reputation: 81
– / Male / Flag
Joined: Feb 2005
RE: PHP Localtime
You can't figure it out. PHP's time function is got from the server, not a browser, therefore the time(); function matches what the server's time is.

If you don't want to use timestamps, use gmtime(); which gives the correct GMT time (instead of the server's default time) :).

Edit: You could use javascript, although it can be difficult and it does contain a small amount of limitations.

This post was edited on 04-11-2007 at 01:57 PM by absorbation.
04-11-2007 01:55 PM
Profile PM Find Quote Report
markee
Veteran Member
*****

Avatar

Posts: 1622
Reputation: 50
36 / Male / Flag
Joined: Jan 2006
RE: PHP Localtime
The reason why PHP cannot do this is because it is a server-side script, meaning it is all done from the server.  Javascript is a client side script and that is why it is very easy to do using javascript.  If you want some help, just give us the exact details of what you are after and we will head you in the right direction ;)
[Image: markee.png]
04-11-2007 02:07 PM
Profile PM Find Quote Report
Eddie
Veteran Member
*****


Posts: 2078
Reputation: 30
33 / Male / Flag
Joined: Oct 2005
Status: Away
O.P. RE: PHP Localtime
quote:
Originally posted by markee
The reason why PHP cannot do this is because it is a server-side script, meaning it is all done from the server.  Javascript is a client side script and that is why it is very easy to do using javascript.  If you want some help, just give us the exact details of what you are after and we will head you in the right direction ;)
k...

Example of wot i want: Wednesday April 11, 2007, 10:22pm thats how i want it layed out :)
...there used to be a signature here :)
04-11-2007 02:23 PM
Profile PM Web Find Quote Report
Ezra
Veteran Member
*****

Avatar
Forgiveness is between them and God

Posts: 1960
Reputation: 31
37 / Male / Flag
Joined: Mar 2003
RE: PHP Localtime
But what do you want to show?

Just a clock function or something with database functions and or  forum posts behind it?
[Image: 1-0.png]
             
04-11-2007 02:24 PM
Profile PM Web Find Quote Report
Eddie
Veteran Member
*****


Posts: 2078
Reputation: 30
33 / Male / Flag
Joined: Oct 2005
Status: Away
O.P. RE: JavaScript Localtime
Just a clock :)
...there used to be a signature here :)
04-11-2007 02:25 PM
Profile PM Web Find Quote Report
Ezra
Veteran Member
*****

Avatar
Forgiveness is between them and God

Posts: 1960
Reputation: 31
37 / Male / Flag
Joined: Mar 2003
RE: JavaScript Localtime
That's easy to find with a quick Google Search

EDIT: First result gave this:

code:
<script language="JavaScript">

<!--
// please keep these lines on when you copy the source
// made by: Nicolas - http://www.javascript-page.com

var clockID = 0;

function UpdateClock() {
   if(clockID) {
      clearTimeout(clockID);
      clockID  = 0;
   }

   var tDate = new Date();

   document.theClock.theTime.value = ""
                                   + tDate.getHours() + ":"
                                   + tDate.getMinutes() + ":"
                                   + tDate.getSeconds();
   
   clockID = setTimeout("UpdateClock()", 1000);
}
function StartClock() {
   clockID = setTimeout("UpdateClock()", 500);
}

function KillClock() {
   if(clockID) {
      clearTimeout(clockID);
      clockID  = 0;
   }
}

//-->

</script>
<body onload="StartClock()" onunload="KillClock()">
<center><form name="theClock">
<input type=text name="theTime" size=8>
<form></center>

This post was edited on 04-11-2007 at 02:38 PM by Ezra.
[Image: 1-0.png]
             
04-11-2007 02:36 PM
Profile PM Web Find Quote Report
Eddie
Veteran Member
*****


Posts: 2078
Reputation: 30
33 / Male / Flag
Joined: Oct 2005
Status: Away
O.P. RE: JavaScript Localtime
ty ezra, but can i have it so its not in a form please :)
...there used to be a signature here :)
04-11-2007 02:39 PM
Profile PM Web Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On