Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Display current date/time in xsl

 
JayaSiji Gopal
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an xml document which uses xsl for transformation to excel.

in the xsl document, i need to also write code to display the current date/time in the format - {$DD-Mmm-YYYY 24HH:MN:SS TZN}" timestamp unwrapped. TZN is user's time zone.

I actually get the idea to use xs:datetime, however, i am unfamiliar with the usage in xsl. Could someone please help me with the syntax?
 
Paul Clapham
Sheriff
Posts: 21316
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There isn't any function in XSLT 1.0 to produce the current timestamp.
 
Dmitrij Beloborodov
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For XSLT 2.0 you have a wealth of date functions, i.e.:



as well as current-date() and current-time().

For XSLT 1 you'll have to use the dates-and-times EXSLT extension package. Here's a usage example for XSLT 1:



The only problem is get date in specific format.
 
Dmitrij Beloborodov
Greenhorn
Posts: 2
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This solution worked out for me. It might help you:

 
smee bond
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for posting the solution Dmitrij Beloborodov. It helped me resolve my problem too!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic