|
|
|
|
![]() ![]() |
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 Another day I might do the binary clock, so tired 2day Cya all! |
|
|
|
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. |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 5th September 2008 - 07:02 AM |