Current location: Hot Scripts Forums » Programming Languages » PHP » PHP clock?


PHP clock?

Reply
  #1 (permalink)  
Old 02-07-05, 07:40 AM
liljoeyjordison liljoeyjordison is offline
Newbie Coder
 
Join Date: Jan 2005
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs down PHP clock?

Hey, I'm pretty new to the whole php "thang" and I wanted to know how I would go about getting a clock on a webpage. I know how to get it to output the date/time with
Code:
$nowtime = date("g, i, s");
However that outputs static text, not very exciting. I then cobbled together virtually everything i know about php and came up with
Code:
$nowtime = date("g, i, s");
do
{
  echo $nowtime;
  
  $checktime = ("g, i, s");
} while ( 0 == 0) ;## to make it infinite
That just outputs an infinite amount of meaningless numbers into my lovely structured webpage.

Any help on this will be greatly appriciated
Reply With Quote
  #2 (permalink)  
Old 02-07-05, 08:54 AM
James Talbot James Talbot is offline
Newbie Coder
 
Join Date: Jul 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Your best bet is to do this with Javascript as it is much easier. I dont think there is a simple way of doing it in PHP without refreshing every second? Anyone know a way?
Reply With Quote
  #3 (permalink)  
Old 02-07-05, 10:16 AM
digioz's Avatar
digioz digioz is offline
Community VIP
 
Join Date: Oct 2003
Location: Chicago, IL
Posts: 2,171
Thanks: 3
Thanked 9 Times in 9 Posts
Here is a Java Applet as an alternative:

http://www.digioz.com/java.php


Another way to do this is to write it in Javascript as James said.
__________________
Reply With Quote
  #4 (permalink)  
Old 02-08-05, 04:19 AM
liljoeyjordison liljoeyjordison is offline
Newbie Coder
 
Join Date: Jan 2005
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
dagnabbit.... Java gives me the jibblies...
Reply With Quote
  #5 (permalink)  
Old 02-09-05, 01:04 PM
moronovich moronovich is offline
Junior Code Guru
 
Join Date: Oct 2004
Posts: 460
Thanks: 0
Thanked 0 Times in 0 Posts
and why do you want php to do it? creating a dynamic clock with php is the same with pinging your server everytime, it's just wasting your bandwith. javascript is a feasible solution (though browser compliance could be another case). you can stick with it, at least till now.
__________________
just an ignorant noob with moronic solution...
Reply With Quote
  #6 (permalink)  
Old 02-10-05, 02:17 AM
SwitchBlade SwitchBlade is offline
Newbie Coder
 
Join Date: Jan 2005
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
<?php
// Configure The Var Below To Your TimeZone
// Ex 2, 0, -2, etc...
$TimeZoneDif = "0";
$nowtime = Date("U");
$AddTime = $TimeZoneDif * 3600;
$YourTime = $nowtime + $AddTime;
echo Date("g, i, s", $YourTime);
?>
Reply With Quote
  #7 (permalink)  
Old 02-10-05, 05:30 AM
liljoeyjordison liljoeyjordison is offline
Newbie Coder
 
Join Date: Jan 2005
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Iunno why I need php, I guess it just annoyed me that I could get half of the problem correct, but not the whole thing, thanks to everyone etc
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 02:22 AM
2 profitable script sites for sale cms-master.com General Advertisements 3 07-03-07 10:17 AM
Punch clock php script godric21ph Script Requests 0 01-21-05 12:37 PM
php with Apache in windows eDevil PHP 3 08-08-04 12:03 AM
100 Web Templates & 10 PHP Scripts for sale! HostersUK.co.uk General Advertisements 0 01-10-04 12:31 AM


All times are GMT -5. The time now is 05:29 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.