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 June 17th, 2010, 04:36 PM
Friend of Wrox
 
Join Date: May 2004
Posts: 109
Thanks: 18
Thanked 0 Times in 0 Posts
Default Convert/Format a unix timestamp

Hi,

I'm using Saxon EE a-la Oxygen 11.2

I am using XSLT as part of a tool chain. It start's off in BASH, goes through an XSLT transformation (or 2), then finally ends up on a PHP web site.

What I want to do is let bash create a time stamp that will eventually be read by PHP, but I would like the XSLT transformation to also have access to the timestamp value and format it for logging or other purposes. There will be other consumers of the data and XSLT may be my last opportunity to format the time stamp information before it goes to one of the other consumer.

Is there a way to format unix time epoch information in XSLT?
__________________
------------------------
Keep Moving Forward

GnuPG Key fingerprint = 1AD4 726D E359 A31D 05BF ACE5 CA93 7AD5 D8E3 A876

Michael Hare
 
Old June 17th, 2010, 05:08 PM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Hopefully the following should help:

http://stackoverflow.com/questions/6...time-with-xslt
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
The Following User Says Thank You to samjudson For This Useful Post:
mphare (June 21st, 2010)
 
Old June 17th, 2010, 07:02 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>Is there a way to format unix time epoch information in XSLT?

If by "unix time epoch information" you mean the number of milliseconds since 1 Jan 1970, then try

xs:dateTime('1970-01-01T00:00:00') + $N * xs:dayTimeDuration('PT0.001S')

which returns an xs:dateTime value, which you can then format using format-dateTime()
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
The Following User Says Thank You to mhkay For This Useful Post:
mphare (June 21st, 2010)
 
Old June 21st, 2010, 03:10 PM
Friend of Wrox
 
Join Date: May 2004
Posts: 109
Thanks: 18
Thanked 0 Times in 0 Posts
Default

Thanks Sam and Michael. Both of your suggestions were what I was looking for.
__________________
------------------------
Keep Moving Forward

GnuPG Key fingerprint = 1AD4 726D E359 A31D 05BF ACE5 CA93 7AD5 D8E3 A876

Michael Hare





Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert UNIX Time to MS Access Corey Linux 4 April 7th, 2009 11:52 AM
Convert Rich Text Format to Ordinary Format in ASP Andraw Classic ASP Basics 1 August 31st, 2007 10:05 AM
Convert UNIX Time to MS Access Corey Access 1 January 23rd, 2006 12:32 AM
XSLT unix timestamp conversion Weezel XSLT 2 January 28th, 2005 02:12 PM
UNIX Timestamp apek PHP How-To 4 January 20th, 2004 02:05 PM





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