Log in

View Full Version : How to add a day suffix to a URL



bakshir
05-01-2009, 06:23 PM
Hi Folks,

I am new to web design and am currently in the process of setting up a website for the team. I am just trying to do the basic stuff before I try to add complex functionality.

There is an automated process which generates a report. The report is called exception_<day>.htm where <day> can be Mon, Tue, ......Sun etc depending on the day its generated.

From my web page I want to be able to goto todays report. This is where my question comes in :

Lets say my URL is http://abc.xyz.com/report/exception_<day>.url

Is there a way of me being able to dynamically change the URL depending on the day. I have had a look on the web and people talk about using a database, PHP, etc. Due to time constraints I am looking for a quick and easy solution.

Any help and/or advice greatly appreciated.

BTW a similar issue exists with another report where the suffix is in the format YYMMDD.

forum_amnesiac
05-02-2009, 06:12 PM
You can use javascript to derive todays date and then format it to suit your needs.

Here's a bit of one that I use, it enables me to build ddmmyyyy or dd-monthname-yyyy.


function showDate()
{
var mydate=new Date();
var year=mydate.getYear();
if (year < 1000) {
year+=1900;
}
var month=mydate.getMonth();
var daym=mydate.getDate();
if (daym<10) {
daym="0"+daym;
}
var montharray=["Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août", "Septembre","Octobre","Novembre","Décembre"];
var alphaDate=(daym+" "+montharray[month]+" "+year);
var numDate=(daym+"/"+month+"/"+year);
}

Apologies for the month name being in French.

bakshir
05-03-2009, 02:50 PM
Thank you for the code above.

It will certainly come in handy for calculating the date in the format I require. Then I will experiment with trying to add the variable at the end of the URl.