Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 1st, 2008, 01:18 AM
Registered User
 
Join Date: Sep 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to format date using XSLT

Hello everyone.
i m using XSLT to convert one xml to other.
when i pick dates from xml it was like 9/9/2005 12:00:00 AM
But when i translated it using XSLT then the result was like 2008-01-18T14:41:21-08:00.
which returns error when saving into database.
so want to convert date time from 2008-01-18T14:41:21-08:00 to 9/9/2005 12:00:00 AM format.

Regards
navi

 
Old September 1st, 2008, 03:13 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

In XSLT 2.0 you can use the format-date() function, in 1.0 you'll need to use low-level string manipulation (substring, concat, etc). You might find a library routine to do it at www.exslt.org.

Incidentally if you're going to illustrate your required format by example, then choose an example that isn't ambiguous - we can't tell whether 9/9/2005 is d/m/y or m/d/y.

Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference
 
Old September 2nd, 2008, 06:36 AM
Registered User
 
Join Date: Sep 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i m using XSLT 1.0
format-date() doesnt work??
any other alternate

 
Old September 2nd, 2008, 07:00 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I gave you several alternatives in my original reply.

(a) use XSLT 2.0

(b) use the EXSLT date/time library at www.exslt.org

(c) use low-level string manipulation (concat, substring, etc)

Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
date format differs, need to force format somehow patricolsson ASP.NET 2.0 Basics 1 December 3rd, 2009 12:53 AM
Convert British format date to American format? fyr PHP How-To 0 December 19th, 2007 03:17 PM
XSLT - Convert the date in different format haixia XSLT 1 August 25th, 2006 11:51 AM
date format differs, need to force format somehow patricolsson HTML Code Clinic 2 January 12th, 2006 05:55 AM
Date format in XSLT rk2203 XSLT 2 November 29th, 2005 04:10 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.