Board index   FAQ   Search  
Register  Login
Board index php forum :: HTML JavaScript

Help with JavaScript code to display time from internet

Javascript coding ..

Moderators: macek, egami, gesf

Help with JavaScript code to display time from internet

Postby nwabunnia » Thu Aug 09, 2012 12:42 am

Please could somebody help me with a script that will display the current time from the internet instead of system/computer time.

I am working on a web based time clocking app and because the system time can be changed, it defeats the whole purpose. If I can get the app to display the internet time ( with a defined time zone) I think it would help.

I am using something like this already:
Code: Select all
var isnMonths=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
var isnDays= new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday");
today=new Date();
var year=today.getYear();
if (year < 2000)
year = year + 1900;

And in the page I want it displayed, I use this:
Code: Select all
<script language="JavaScript" type="text/javascript">
+isnDays[today.getDay()]+", "+isnMonths[today.getMonth()]+" "
+today.getDate()+", "+ year + " "+clckh+":"+clckm+" "+clck+"</B>");

It will just display the system time.

Any suggestions would be appreciated.

New php-forum User
New php-forum User
Posts: 4
Joined: Mon Jul 02, 2012 1:00 pm

Re: Help with JavaScript code to display time from internet

Postby Nullsig » Thu Aug 09, 2012 12:34 pm

You would have to use AJAX to retrieve the time from a remote site.

JavaScript by itself is client side only. Which means that you will only be able to use the client's computer
User avatar
php-forum Fan User
php-forum Fan User
Posts: 981
Joined: Thu Feb 17, 2011 6:52 am
Location: Racine, WI

Return to JavaScript

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.