Jul 26, 2008

Including An Imgs Clock For Your Web - PHP Tutorial

Free Web Hosting, No Ads > CONTRIBUTE > Tutorials

free web hosting

Including An Imgs Clock For Your Web - PHP Tutorial

NeOniX
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!

 

 

 


Reply

FirefoxRocks
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.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : including, imgs, clock, web, php

  1. Mp3 (compressed Digital Audio Including Aac, Mp3 And Such) Vs Cd Vs Tape Vs Vinyl
    (3)
  2. Analog Clock
    (4)
    ok so i was bored and was inspired by the php clock topic to make this dynamic image of an analog
    clock: so anyway here's the source code: CODE <?php /* All images and lines of code
    were written/drawn from scratch by alex... */ header("Content-type:
    image/jpeg"); function
    newclockhand($time,$color,$length,$thickness){ global $clock;
    imagefilledpolygon($clock,array(96,89,99-$thickness+cos(deg2rad($time
    +90))*2,92+$thickness+sin(deg2rad($time+90&#....
  3. Background Image Swap Script
    Change a Background Image based on clock time (15)
    Background Image Changer Script To swap the background image from your CSS file according to the
    Server Clock Time. 1.) In your CSS file, add the following rule: CODE body {
        background: url(time.png); } 2.) Create a "folder" named time.png. 3.) Into the
    folder, place three images named morning.png, day.png, night.png. 4.) Also, in the same folder,
    create an index.php file and copy/paste the following script. CODE <?php $hour =
    date('H'); if ($hour < 12 ) {     $image =
    "morning.png"; } ....
  4. Alarm - Free Digital Clock
    a great digital alarm clock! (0)
    *** Some one tell me how to delete posts*** seems i posted in the wrong section, sorry for this....
  5. Elprime Clock Pro - Review
    a very nice visual enhancement (1)
    Elprime Clock Pro - Review This software adds an analogue clock face to your desktop.
    You can opt to have the clock on top of all your programs or only have it show when it all programs
    are minimised (show on desktop). An incredibly useful feature is that when you put your mouse over
    the clock, it gradually invisibilises meaning that you can read text/click on buttons that the clock
    would have been hiding. The really nice thing about this visual enhancement is that you can select
    from a variety of skins: 21 come pre-installed and about 40 skins are download....
  6. Php Help Needed Including File In A Page.
    (2)
    i'm a noob in php programming, i can understand and modify php programs, but i dont know to
    write on my own. So please somebody who is well versed in php help me. My need is, I'm
    currently builiding a knowledge base website , i've my own design for the website, check here,
    http://laschatz.info/kzone/ Each page in the left hand site has a tree navigation of all the
    topics available. Since this information must be same in all the pages, presently I need to change
    all the pages after adding a new category. Could you please help me in such a way that I can ad....
  7. Poems Made By Request
    Including short lines for sigs (0)
    Everyone here seems so willing to give their gorgeous artwork. Me, I hate my drawing (Although
    I'm slowly recognizing this is due more to perfectionism that me being honestly HORRIBLE;
    I'm still only average, though.) and I've just started image modification, so sigs are still
    in the future. But one thing I can do: WRITE! ^-^ So, here's my offer! You want
    something poetic written, PM me or drop a request in this topic. Replies will be given in the same
    manner, unless requested otherwise. For my personal stuff, I tend towards a freeform style. ....
  8. Help! Not Able To Access The Entire Trap.com
    Including my account (3)
    A few minutes from posting this I was not able to access the trap17.com or trap17.com/forums and
    not even my account . But now I am able to access them. I wonder what made them inaccessible for a
    few minutes. Could someone make it clear what made this site inaccessible.....
  9. How To Make Youtube Embedded Videos Viewable On All Browsers
    including on Opera browser which is actually not viewable with embedde (3)
    Firstly, I've noticed that embedded YouTube videos on personal websites, or any sites not on
    YouTube's domain, cannot be viewed on Opera browser. In other words, the codes given by YouTube
    to embed the videos on your site does not have support for Opera browser. However I've found out
    a trick to do so. Here's how.. This is the original code given by YouTube to embed to your own
    website. Copy this codes and paste into the source of your site. CODE <object
    width="425" height="350"> <param name="movie" value="....
  10. Clock Hanging In The Air
    Levitating Clocks (18)
    It seems to be magic when you see this clock hanging in the air with no support. But its the
    magnetic force which plays a major role. Just plug the base (which has to be bought alongwith the
    clock) and adjust the clock in between until there is a beep indicating the right place. The
    levitating clock uses the magnetic force to float an LCD clock inside a funny looking base. It also
    features an auto-rotate mechanism to spin objects clockwise, or counter-clockwise (as well as the
    clock you can buy an optional floating space shuttle). I think this is probably best us....
  11. Windows Xp Clock
    (2)
    How can I make the clock in the system tray display seconds as well as hours and minutes?....
  12. Cpus With 5-ghz Clock Speeds On Their Way
    (11)
    Well according to Silicon Valley, 5 GHz CPU's are on their way, which are suppose to be feasible
    and hitting our shelves soon.. Transitior counts doubling from 1 billion to 2 billion in 2 years,
    and to 4 billion in 4 years.
    QUOTE Intel and AMD have said CPU clock speeds -- measured in gigahertz -- will
    not increase to the same degree as in years past due to constraints in power consumption and heat.
    However, the companies will take advantage of increasing chip densities to pac....
  13. Ibm Promises 10 Times Faster Wifi
    operates at a clock speed of 60 GHZ at 630 Mbps (3)
    QUOTE The chip is based on the evolving IEEE 802.15.3c specification for wireless
    communication, which utilizes frequencies higher than the Wi-Fi or any other wireless standard. IBM
    said that the chip operates at a clock speed of 60 GHZ , far faster than the standard 2.4 gigahertz
    or 5 gigahertz speeds that WiFi wireless networking chips use today. In the lab, Gaucher said
    IBM's prototype chip could transfer data at 630 Mbps , and could improve in a few years to
    anywhere from 1 gigabit a second to 5 gigabits a second. Full article : http://www.cdrinfo.c....
  14. Flying Alarm Clock
    yes its true (33)
    I heard about this on a tech site a couple of days ago and I havent been able to find out anything
    else about it. Supposedly, it goes off in the morning and if you hit the snooze button it will fly
    around the room chirping until you catch it and turn it off. If anyone has any other information on
    this or if there is anywhere to buy it please let me know because I am really interested in
    purchasing one of these as I am the type of person that will just keep ihitting the snooze button.....
  15. Set Alarm Clock
    set alarm clock in your computer (4)
    Hello Set an alarm that will play any sound from your computer You can even select a
    snooze time after it sounds. Awesome! Visit this sites
    http://javascript.internet.com/clocks/alarm-clock.html ....
  16. Customizing Windows. Desktop And Logon Screen Imgs
    The best tools/sites/images! (18)
    If you want to add a cool image for your desktop, visit this sites: http://www.belchfire.net/
    http://www.deviantart.com/ http://www.getskinned.org/ http://www.lighttek.com/
    http://www.shellcity.net/ http://www.stardock.com/ http://www.themexp.org/
    http://www.wincustomize.com/ http://www.xpthemes.com/ I Personally love the xpthemes, themexp
    and deviantart to download cool images for desktops, but the others are also very good.
    ----------------------------------------- konfabulator If you want to add pretty cool widgets to
    your desktop, th....
  17. Digital Clock
    the finest moment of evolution (5)
    http://www.yugop.com/ver3/stuff/03/fla.html Speaking of The Deathclock post...I present to you
    a real working clock...the rumor has it that it took them 4 years in completing. LMAO I can see why.
    It's ingenious, actually! Very well thought out plan but what a waste of resources and
    bandwidth. But still, I can't get enough /laugh.gif' border='0' style='vertical-align:middle'
    alt='laugh.gif' /> ....
  18. > Google Can Find Anything.. Including Credit Card
    (4)
    QUOTE Source: ZDNet Simple queries using the Google search engine can turn up a handful of
    sites that have posted credit card information to the Web, CNET News.com learned on Tuesday. The
    lists of financial information include hundreds of card holders' names, addresses and phone
    numbers as well as their credit-card data. Much of the credit-card data that appears in the lists
    found by Google may no longer be valid, but CNET called several people listed and verified that the
    credit cards numbers were authentic. The query, the latest example of "Google hacking," h....
  19. Needs Self-resetting Countdown Clock
    any help? (2)
    HEy, I hope i can post and ask for help here without getting into trouble. Anyways, I searched
    the web for countdown clocks and i just cant fid what i am looking for; What i find is a bunch of
    graphics, or generators that generate for like days and years at a time. What i am looking for is a
    clock that counts down from 24hrs to zero then resets hr:m:sec format. With so many scripts out
    there about countdown clocks i think it would be seemingly easy for those who know Java. Changed
    Topic Title from Html N00b, Needs Some Java Help to Needs Self-Resetting Countdown....
  20. Including Files In Asp
    Using (1)
    I'm making a page (in ASP2.0 with VBScript) wich has to include a file but the path to it is
    composed. Normally inluding a file is done using <!--#INCLUDE FILE="file.asp"--> But
    the url to the file is now composed as I said trough some variables: Server.MapPath(conPath &
    Request.QueryString("p") & "/index.asp") This whole bunch (in an example case the variable should
    be "./Conten/Main/Home/index.asp" which shoul be included. But how do I include such a variable
    since next two tries of me didn't work: <!--#INCLUDE FILE= --> Neither wor....
  21. Php Parse Error
    Including Variable in post (2)
    ok this is my config script that runs my site: CODE <? # Set up info for left column on the
    top page: # It should begin with html tag <td> and finish with tag </td>
    $top_leftcol=" <td width='195' bgcolor='#eeeeee'
     valign='top'> <table width='100%'  bgcolor='#777799' border=0
    cellspacing='0' cellpadding='0'> <tr><td> <font
    FACE='ARIAL, HELVETICA' color='#ffffff' size='-1'>  
    <b>MMORPG Trade Center<....
  22. Including Classes/lib's Twice
    (1)
    I'm using Dev-C++ as a compiler. (To use a classroom assignment as an example,) here is my
    problem...I've got classes Dog and Cat, which inherit from class Animal, (which uses iostream,
    stdlib, and some classes created by students) When I include both Dog and Cat in a new file, I get
    errors because I'm including libraries twice. (iostream included from Dog, and from Cat...)I can
    get around the problem by having Dog inherit Animal, and Cat inherit Dog (which sounds pretty
    idiotic, I know..I was just testing to see if the problem was really what I thought it w....
  23. Including Php-made Images In A Page?
    (5)
    Say you have this script that makes an image, and you want to include it in another page. Would you
    just use ? I'd test it right now, but all my PHP image stuff is on my school's server,
    which is currently down.....
  24. Is The Army Clock Still Ticking?
    (17)
    I looked at how many wizard I have and at the start of the day, I thought I had 700 and some. It
    looks like I have nearly a thousand now. Did I not pay attention this morning? If the clock is still
    ticking the first people back on the Army system are really going to clean up? If the clock is still
    ticking I don’t know a fair way to start except announcing a start time at which point the server
    will probably get loaded down again. Shall, I be plundered or be a plunder after the next restart if
    it ever comes. ....
  25. Kingdom Hearts 2 And Halo 3 Including Ff12
    who will prevail (6)
    i really don't know. there are a lot of people arguing over them i really can't dedcide.
    if i were a top gamer person then it would be easy to choose. until then who has info on the best
    game? /huh.gif' border='0' style='vertical-align:middle' alt='huh.gif' /> /ph34r.gif'
    border='0' style='vertical-align:middle' alt='ph34r.gif' /> ....
  26. 6 Script
    Clock / Password / BookMark / FavIcon / Back and forward but (0)
    1 - Script Back And forward Button CODE <script LANGUAGE="JavaScript">
    <!-- hide this script tag's contents from old browsers function goHist(a) {
    history.go(a); // Go back one. } // <!-- done hiding from old browsers -->
    </script> <form METHOD="post"> <input TYPE="button"
    VALUE="BACK" onClick="goHist(-1)"> <input TYPE="button"
    VALUE="FORWARD" onClick="goHist(1)"> </form><!-- -->
    ....
  27. Php Clock
    source Code (7)
    Hi Every one i find this code its very easy simple php clock i think you can use it /blink.gif'
    border='0' style='vertical-align:middle' alt='blink.gif' /> CODE <? // Binary Clock //
    script copyright© 2002 Andreas Tscharnuter // questions? contact: psychodad@psychodad.at ||
    [url=http://www.psychodad.at/clock/]http://www.psychodad.at/clock/[/url] //
    free to use, copy and modify but leave comments untouched;) // just include this file where
    your binary clock should appear // version 1.2   03 September 2003 // below you can ....
  28. Nice Flash Clock
    (1)
    I Find This clock (SWF) Its Really Nice Clock /blink.gif' border='0'
    style='vertical-align:middle' alt='blink.gif' /> For Designers Is good To be Find This samples and
    learn there Technic see this :: http://www.lares.dti.ne.jp/~yugo/storage/m.../29/bclock.html ....
  29. How To Restore Back Up Website?
    including files, folders & database (3)
    I would like to know how to restore my site which I BACK UP sometime ago. I have back up the full
    directory. I would like to know how to restore everything including MySQL database. Please give line
    to line description if possible. Thanks in advance.....
  30. Flash Clock
    Great for your website (4)
    Here: http://script4you.freesuperhost.com/clock41.html If you don't know how to download
    it from the browser and if you don't know how to change it to a different width and height for
    you to add to your website, just reply to this post and i will send in the size details you want.....

    1. Looking for including, imgs, clock, web, php

Searching Video's for including, imgs, clock, web, php
Similar
Mp3
(compressed
Digital
Audio
Including
Aac, Mp3 And
Such) Vs Cd
Vs Tape Vs
Vinyl
Analog Clock
Background
Image Swap
Script -
Change a
Background
Image based
on clock
time
Alarm - Free
Digital
Clock - a
great
digital
alarm
clock!
Elprime
Clock Pro -
Review - a
very nice
visual
enhancement
Php Help
Needed
Including
File In A
Page.
Poems Made
By Request -
Including
short lines
for sigs
Help!
Not Able To
Access The
Entire
Trap.com -
Including my
account
How To Make
Youtube
Embedded
Videos
Viewable On
All Browsers
- including
on Opera
browser
which is
actually not
viewable
with embedde
Clock
Hanging In
The Air -
Levitating
Clocks
Windows Xp
Clock
Cpus With
5-ghz Clock
Speeds On
Their Way
Ibm Promises
10 Times
Faster Wifi
- operates
at a clock
speed of 60
GHZ at 630
Mbps
Flying Alarm
Clock - yes
its true
Set Alarm
Clock - set
alarm clock
in your
computer
Customizing
Windows.
Desktop And
Logon Screen
Imgs - The
best
tools/sites/
images!
Digital
Clock - the
finest
moment of
evolution
> Google
Can Find
Anything..
Including
Credit Card
Needs
Self-resetti
ng Countdown
Clock - any
help?
Including
Files In Asp
- Using
Php Parse
Error -
Including
Variable in
post
Including
Classes/lib&
#39;s Twice
Including
Php-made
Images In A
Page?
Is The Army
Clock Still
Ticking?
Kingdom
Hearts 2 And
Halo 3
Including
Ff12 - who
will prevail
6 Script -
Clock /
Password /
BookMark /
FavIcon /
Back and
forward but
Php Clock -
source Code
Nice Flash
Clock
How To
Restore Back
Up Website?
- including
files,
folders
&
database
Flash Clock
- Great for
your website
advertisement



Including An Imgs Clock For Your Web - PHP Tutorial



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE