# A bit of code help needed

**URL:** <https://forum.kirupa.com/t/a-bit-of-code-help-needed/139799>\
**Category:** Uncategorized\
**Created:** [March 5, 2005, 7:40pm UTC](https://forum.kirupa.com/t/a-bit-of-code-help-needed/139799 "2005-03-05T19:40:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![spectreman](https://avatars.discourse-cdn.com/v4/letter/s/a5b964/32.png) [@spectreman](https://forum.kirupa.com/u/spectreman)\
**Post date:** [March 5, 2005, 7:40pm UTC](https://forum.kirupa.com/t/a-bit-of-code-help-needed/139799/1 "2005-03-05T19:40:03Z")

</div>

hello everyone,

regarding the kirupa tutorial on the news editor found here:  
[http://www.kirupa.com/web/xml/examples/newseditor.htm](http://www.kirupa.com/web/xml/examples/newseditor.htm)

how do i edit the following code so the xml file displays only the date, and not the time? i can’t figure it out…i tried deleting the .getTime, but that doesn’t work.

thanks!

var max\_news\_items = 50;

GetTitleText = function(news\_xml, entry\_index){  
var entries = news\_xml.firstChild.childNodes;  
var title\_element = entries[entry\_index].firstChild;  
return title\_element.firstChild.nodeValue;  
}  
GetBodyText = function(news\_xml, entry\_index){  
var entries = news\_xml.firstChild.childNodes;  
var body\_element = entries[entry\_index].firstChild.nextSibling;  
return body\_element.firstChild.nodeValue;  
}  
GetEntry = function(news\_xml, index){  
var entries = news\_xml.firstChild.childNodes;  
return entries[index];  
}  
GetNewsCount = function(news\_xml){  
var entries = news\_xml.firstChild.childNodes;  
return entries.length;  
}

ShowNews = function(news\_xml){  
if (!news\_xml.firstChild.hasChildNodes()){  
content\_txt.text = “No news available.”;  
return (0);  
}  
var entries = news\_xml.firstChild.childNodes;  
content\_txt.text = “”;  
for (var i=0; i\<entries.length; i++){  
var title = GetTitleText(news\_xml, i);  
var body = GetBodyText(news\_xml, i);  
content\_txt.htmlText += entries\*.attributes.date + “\<br\>”  
content\_txt.htmlText += “\<b\>” + title +"\</b\>\<br\>"

```
	content_txt.htmlText += body +"&lt;br&gt;&lt;br&gt;";
	content_txt.htmlText += "¯¯¯¯¯¯¯¯¯¯&lt;br&gt;" 
}

```

}

AddNewsEntry = function(news\_xml, title, body){  
var entryNode = news\_xml.createElement(“entry”);  
entryNode.attributes.date = new Date().toString();

```
if (title == "") title = "(none)";
var titleNode = news_xml.createElement("title");
var titleText = news_xml.createTextNode(title);
titleNode.appendChild(titleText);
entryNode.appendChild(titleNode);

if (body == "") body = "(none)";
var bodyNode = news_xml.createElement("body");
var bodyText = news_xml.createTextNode(body);
bodyNode.appendChild(bodyText);
entryNode.appendChild(bodyNode);

if (news_xml.firstChild.hasChildNodes()){
	news_xml.firstChild.insertBefore(entryNode, news_xml.firstChild.firstChild);
}else news_xml.firstChild.appendChild(entryNode);

while (GetNewsCount(news_xml) &gt; max_news_items){
	news_xml.firstChild.lastChild.removeNode();
}

```

}

EditNewsEntry = function(news\_xml, node\_index, title, body){  
var entry = GetEntry(news\_xml, node\_index);  
if (title == “” && body == “”){  
entry.removeNode();  
return (0);  
}else{  
if (title == “”) title = “(none)”;  
if (body == “”) body = “(none)”;  
}  
entry.attributes.date = new Date().toString();  
var titleTextNode = entry.firstChild.firstChild;  
var bodyTextNode = entry.firstChild.nextSibling.firstChild;  
titleTextNode.nodeValue = title;  
bodyTextNode.nodeValue = body;  
}

SaveNews = function(news\_xml){  
content\_txt.htmlText = “\<i\>Saving and Loading…\</i\>”;  
news\_xml.xmlDecl = “”; // fixes duplication bug  
news\_xml.sendAndLoad(save\_script, news\_xml);  
}  
RefreshNews = function(news\_xml){  
content\_txt.htmlText = “\<i\>Loading…\</i\>”;  
news\_xml.load(xml\_file+"?"+new Date().getTime());  
}
