current date as gif
- Started
- Last post
- 16 Responses
- smartK
http://www.netymology.com/
on the right side the current date is shown - it's a gif file.how is this file generated?
- smartK0
ok I found lots of infos on how to show the current date like http://www.atfreeweb.com/resourc…
BUT how can I make it display a special gif file?
(I'd make a library of numbers and months names to display the date)
- jevad0
javascript and document.writes
- dprevite0
or PHP
- smartK0
thx so far
alright how can I tell the document which images has to be displayed using conditions (in java-script)
- mitsu0
on the server-side get the month and using an if / else or select case / switch case conditional and show the appropriate .gif. do the same for the day. and then the year, or just hard code the year, depending on how often you redesign your site. server-side scripts will reflect the date of the server, whereas javascript will show the local date/time of the user.
- mitsu0
it would work something like this:
let us know if you need a more thorough example.if(month==1){
img_element.src="jan.gif";
}else if(month==2){
img_element.src="feb.gif";
}else{
//you get the point
}
- smartK0
thanks a lot mitsu, though I'd be glad if you could provide information on how to get the current date using ASP odr PHP
- mitsu0
simple, just change the src to point to your image directory:
no conditionals needed here either:Response.Write("")
Response.Write("")
Response.Write("")
- mitsu0
i'm sure you can tell, but that's ASP, by the way.
- club4560
Damn where did my php code go?? I'll try again..
Just place this instead of PHP opening and closing script tags:
date("l - F j, Y");
- J0
Has no one noticed that it does the date as gif thang on THIS site too!
;)
- unknown0
the same way NT generates theirs
:)
- CAJTBr0
hey i wouldn't use the if/then/else method - it just gets way too messy. just set up 3 arrays with numbers as indexes and gif filenames as contents.
or even simpler if you're wanting to stick with clientside. make a directory full of images like
day_01.gif
day_02.gif
day_03.gif
...month_01.gif
...and then have a little function which does the following:
set three variables (day, month, year)
sets three new variables consisting of the absolute path of this directory, followed by 'day_' (and the same for month_ and year_) followed the day (and then month and then year) variable followed by '.gif' .then document write them out where you want them on the page.
even more simply, as you seem to suggest that you have php capabilities. in php 3 and later, you can write text to an image. so you could just have a blank gif file, get the date, and write it to this file. there's a tutorial here:
- kjensen0
You use PHP with the GIF module installed. Then you make the gif on the fly using the date function and the gif API.