PDA

View Full Version : current date in address


alochin
11-18-2007, 06:35 AM
Hi,

How do you add today's date inside an <a href=...> tag?

For example, today is November 17, 2007. I need the href tag to look like this:

<a href="phpscript.php?directory=11_17_2007">Today</a>

This will launch a php script that will browe a directory created today.
The php script is a slideshow.
The directory is created by a cctv system that stores pictures taken today. A new directory is created everyday.
By clicking on the link, I can see what happened today.

Right now, it is not working. You guys have an idea, or you know a place I should ask (I am not sure it is an html question - maybe a php question?).

Thanks in advance.
Andre.

rpgfan3233
11-18-2007, 07:58 AM
If you are thinking of using an automatic way, there is none with X/HTML or CSS, unless you posted in the wrong forum. :p

You COULD do it with JavaScript, but it would be easier using PHP's date() function, not to mention usable by even those with JavaScript turned off (your link would anyway...)

Check out PHP's date() (http://www.php.net/date) function. You're probably gonna want something like:
$current_date = date('m_d_Y'); //January 2, 1970 would be 01_02_1970
or
$current_date = date('n_j_Y'); //January 2, 1970 would be 1_2_1970

It depends on the way the system would be organized. There are four possible ways to do it based on your description:
m_d_Y = 01_02_1970
m_j_Y = 01_2_1970
n_d_Y = 1_02_1970
n_j_Y = 1_2_1970

I hope that helps.

Donkey
11-18-2007, 02:52 PM
Or as an SSI use:

Today is <!--#echo var="DATE_LOCAL" -->

You may have to give the page the shtml suffix unless you have used htaccess to allow .html to work with SSI's