Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Including An Imgs Clock For Your Web, PHP Tutorial
NeOniX
post Jun 17 2006, 11:45 PM
Post #1


Newbie [Level 1]
*

Group: Members
Posts: 22
Joined: 17-June 06
From: Nebuchadnezzar, dock 6, Zion
Member No.: 25,271



When you load a page, is nice to see what day it is, and the time of the moment of loading the page, but isn't nicer to see the time with custom imgs?, i.e. you could put a binary clock at the top of your web, ect.

So, there's another php microtutorial that i hope it's going2help someone.


First of All, you have to set in your mind clearly what kind of clock want to put in your web (always with numbers, digital), and then, you have to do in Photoshop or your chosen image editor, the images for the numbers. In example, if you want a classic digital clock that prints '12:34 am', you'll need to do images from the 0 to the 9, and the am/pm indicator. If you want a Internet Swatch Time clock that prints '@345' you'll need to do the numbers and the @ only, ect.

For binary clocks, i recommend you to do from the 0 to the 111011 (with black/white dots representing 0/1), so you'll need to do 59 imgs. I recommend that cuz it's easier to embed on you want. If you only wanna do 2 images (black and white dot), we'll need to do some phpmaths that i'll explain further.


We'll start for a simple clock, we assume that you have a root folder '/' and an images folder '/img/', so you have to create a page, in example we're going to name it clock.php (in the example, a 24h clock).

CODE
<?
$time1=date('H'); // Hours
$time2=date('i'); // Minutes
settype($time1,integer);
settype($time2,integer);

$h1=((int)($time1/10));
$h2=($time1-($h1*10));
$m1=((int)($time2/10));
$m2=($time2-($m1*10));
echo '<img src="img/"'.$h1.'.jpg">';
echo '<img src="img/"'.$h2.'.jpg"> '; // Note that I have left a lil space separating the Hours from the Minutes.
echo '<img src="img/"'.$m1.'.jpg">';
echo '<img src="img/"'.$m2.'.jpg">';
?>

Remember you MUST place imgs from 0.jpg to 9.jpg. It could look nicer if your images are png with transparencies (only our loved firefox will be able to view it, but i think all we use it wink.gif), if you want to, only will have to change the .jpg extension by the .png (or whatever you want) on the php code.

Another day I might do the binary clock, so tired 2day sad.gif, but i may edit that same post, so remember visiting it again lol.

Cya all!
Go to the top of the page
 
+Quote Post
FirefoxRocks
post Jun 18 2006, 08:02 PM
Post #2


Super Member
*********

Group: Members
Posts: 273
Joined: 14-April 06
From: Ontario, Canada, North America, Planet Earth
Member No.: 21,845



Thanks for the tutorial. I really suck at PHP (Prehypertext Processor). I will consider keeping a log of PHP tutorials, they might be really helpful someday.

Your tutorial can add benefit to all websites.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. How To Restore Back Up Website?(3)
  2. Php Clock(7)
  3. 6 Script(0)
  4. Kingdom Hearts 2 And Halo 3 Including Ff12(6)
  5. Is The Army Clock Still Ticking?(17)
  6. Including Php-made Images In A Page?(5)
  7. Including Classes/lib's Twice(1)
  8. Php Parse Error(2)
  9. Including Files In Asp(1)
  10. Needs Self-resetting Countdown Clock(2)
  11. > Google Can Find Anything.. Including Credit Card(4)
  12. Digital Clock(5)
  13. Customizing Windows. Desktop And Logon Screen Imgs(18)
  14. Set Alarm Clock(4)
  15. Flying Alarm Clock(33)
  1. Ibm Promises 10 Times Faster Wifi(3)
  2. Cpus With 5-ghz Clock Speeds On Their Way(11)
  3. Windows Xp Clock(2)
  4. Clock Hanging In The Air(18)
  5. How To Make Youtube Embedded Videos Viewable On All Browsers(3)
  6. Help! Not Able To Access The Entire Trap.com(3)
  7. Poems Made By Request(0)
  8. Php Help Needed Including File In A Page.(2)
  9. Elprime Clock Pro - Review(1)
  10. Alarm - Free Digital Clock(0)
  11. Background Image Swap Script(15)
  12. Analog Clock(4)
  13. Mp3 (compressed Digital Audio Including Aac, Mp3 And Such) Vs Cd Vs Tape Vs Vinyl(3)


 



- Lo-Fi Version Time is now: 5th September 2008 - 07:02 AM