XSLT: convert ISO 8601 DateTime format

Today I did a little bit of XSLT coding and stumbled over the problem to convert ISO 8601 date strings into a more human readable format.

Specifically I wanted to turn a date of the form 2008-04-10T16:12:27Z to the typical german format of 10.04.2008 16:12:27 and spit the whole thing out as HTML to display it on a webpage.
After a bit of time I came up with the following XSLT (sanitized):



	
	
		
		
			
				
				
			
			dtstart
			
				
			
		
		
	
	
	
	
			
	
	
			
	  
	
			
	
	
			
	
	
			
	
	
			
	
	
			
	
		
		
		
		
		
		
		
		
		
		
		
	

Using this example and the mighty power of substring() it should be pretty easy to convert any date format into an other one.

1 comment

  1. Thank you for your post about XSLT date convertions. It was very useful. I was looking for a way to convert a dates without using explicit Xpath date convertion functions and you gave just that. Thank you again.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.