PDA

View Full Version : Convert date created by Listgarden


schwarznavy
05-19-2008, 01:18 PM
Hello,

I use ListGarden to create RSS feeds and also create an html file from the feed.

ListGarden allows you to customize the html file with a template. You can modify the code to use for the top part of the html file, the code to use for each item, and the code for below the items. I have done this.

The only thing I don't like is that the date format ListGarden uses for items are in this format: "Day, monthday Month year hour:min:sec GMT",
(e.g., Wed, 08 Oct 2003 19:29:11 GMT).

I was thinking there might be a way to use JavaScript to convert that format into something else. For example, "October 8, 2008" or "Wednesday, Oct. 8, 2003" or whatever I want.

I don't know much about JavaScript. But I do know that you often have to put some code into the top part of the html file, in the <head> and then you have to put some part in the <body>. I should be able to do that in ListGarden.

Does anyone know a simple way to accomplish this?

Thank you very much.
Matt

Philip M
05-19-2008, 03:49 PM
<script type = "text/javascript">

var days = new Array("Sun", "Mon", "Tues", "Weds", "Thurs", "Fri", "Sat");
var months = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
var now = new Date();
var yy = now.getYear();
var mm = now.getMonth();
mm = months[mm];
var dd = now.getDate();
var dy = now.getDay();
dy = days[dy];

// now arrange your date in desired order

dt = dy + " " + dd + " " + mm + " " + yy

alert (dt);
document.write (dt);

</script>

That covers today's date. If you want to convert some other date generated by Listgarden then simply manipulate the order of the variables:-

var newDay = Month + " " + monthday + " " + year;

It is best to place your scripts in the body immediately after the <body> tag.


Quizmaster: Which African country gives its name to the complaint known as 'gippy tummy'?
Contestant: Venezuela.