Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

data format 1980-03-31T00:00:00

Status
Not open for further replies.

flaviooooo

Programmer
Feb 24, 2003
496
0
0
FR
Hi,

in my XML-file, the date format (which I exported from an Accesstable) is like 1980-03-31T00:00:00. When I display the date on my webpage, this format is obviously not very nice.

Is there a way to display it as 31-03-1980 or maybe even 31 March 1980?

greetings
 
XML uses ISO-8601 (also known as RFC-3339) for date formats. If you want to display it in another format, you will need to refer to your language's reference manual.

For example, in VB, you use the Format$() command to specify date formats. In C#, you would use the XmlConvert object to convert your ISO-8601 date to a .NET DateTime object, on which you can then use the standard ToString() method formatting.

In either case, you should pay attention to the locale of your user. Japanese users like to see YYYY-MM-DD, US users like to see MM-DD-YYYY, and European users like to see DD-MM-YYYY. In VB6, it will use the control-panel format of the current logged-on user. In C#, it will also use the format of the current logged-on user, but you can also specify a different culture (if you're writing a Web app and your users are multi-national).

Don't forget that format strings are case-sensitive. And don't forget to convert back to ISO-8601 before storing your date into your XML document.

Chip H.
 
Hey, thanks for the response. Can you help me with the converting part?
I have written a little script (and implemented that in HTML)
This is the script:

<script type=&quot;text/vbscript&quot;>

set xmlDoc=CreateObject(&quot;Microsoft.XMLDOM&quot;)
xmlDoc.async=&quot;false&quot;
xmlDoc.load(&quot;../spelers.xml&quot;)

path=&quot;/spel/spelers[nummer=62]/mydate/text()&quot;
set nodes=xmlDoc.selectNodes(path)

for each x in nodes
document.write(x.xml)
document.write(&quot; &quot;)
next

</script>

The 'mydate' thingy is the strange looking date that i'd like to convert to a regular format. Any thoughts?
I've tried replacing text() by date() without success.

Thanks in advance
 
Hi there

You can also do a workaround by seperating the date in the Access mdb(adp)and then implementing it a the sample code below.

good luck
HOTRECA
[noevil]

<script type=&quot;text/vbscript&quot;>
txt=&quot;<h4 align=center>spel dag:</h4>&quot;
document.write(txt)
set xmlDoc=CreateObject(&quot;Microsoft.XMLDOM&quot;)
xmlDoc.async=&quot;false&quot;
xmlDoc.load(&quot;data/date.xml&quot;)
path=&quot;xml/rs:data/z:row/@day/text()|xml/rs:data/z:row/@month/text()|xml/rs:data/z:row/@year/text()&quot;
set nodes=xmlDoc.selectNodes(path)
for each x in nodes
document.write(x.xml)
document.write(&quot; &quot;)
next
</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top