SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Evangelist Ian R. Gordon's Avatar
    Join Date
    Feb 2004
    Location
    New York
    Posts
    474
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Post Dynamically Generate Calendar Day/Month Image

    Hello,

    I am trying to figure out out how I can use PHP to dynamically generate the day and month on an image, I know I could break it up into three different images and then do it that way but, I want one solid image.

    Here is an example of what I mean: http://www.pen-cei-guest-house.co.uk...gion-wales.htm

    On the sidebar to the left you seen under Latest News, there is the day and month, how can i accomplish this with PHP?
    Ian Gordon
    CSS / XHTML / PHP Programmer
    http://www.iangordon.us

  2. #2
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,395
    Mentioned
    81 Post(s)
    Tagged
    3 Thread(s)
    I would think you can do it in either GD or ImageMagick.

    Get the current time, format it, put it into a variable then write it to an image.

    I would think it is easyer to do in ImageMagick ( shorter anyway ) as in GD you would need to get the length of the text and work out how to center it on the image; ImageMagick all you need to do is center it. Although I suppose once you have written the code its done for everytime.

    Check out the code here http://www.rubblewebs.co.uk/imagemag...o=Label_GD.jpg and http://www.rubblewebs.co.uk/imagemag...o=Label_IM.jpg

  3. #3
    Keep it simple, stupid! bokehman's Avatar
    Join Date
    Jul 2005
    Posts
    1,935
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use one image as a CSS background and do the rest with HTML and CSS. Don't make an image for each; it's a waste of resources.

  4. #4
    SitePoint Evangelist Ian R. Gordon's Avatar
    Join Date
    Feb 2004
    Location
    New York
    Posts
    474
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was thinking of that too, I guess I could use javascript or PHP to do it...
    Ian Gordon
    CSS / XHTML / PHP Programmer
    http://www.iangordon.us

  5. #5
    Keep it simple, stupid! bokehman's Avatar
    Join Date
    Jul 2005
    Posts
    1,935
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Ian R. Gordon View Post
    I could use javascript or PHP to do it...
    You don't need either. Just HTML and CSS.

  6. #6
    SitePoint Evangelist Ian R. Gordon's Avatar
    Join Date
    Feb 2004
    Location
    New York
    Posts
    474
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If the date changes from day to day, how do I retain the value using just HTML and CSS? I would have to use some scripting to determine the day and month.
    Ian Gordon
    CSS / XHTML / PHP Programmer
    http://www.iangordon.us

  7. #7
    Grumpy Minimalist
    Join Date
    Jul 2006
    Location
    Ontario, Canada
    Posts
    424
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Generate the date using PHP, and echo the output into your HTML. You don't need JavaScript for anything, and the generation of the "image" should be done by the CSS.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •