473,385 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

timestamp

Hello,

using XSLT 2.0 I can get a timestamp with the following line:
<xsl:value-of select="current-dateTime()"/>
How can I format the date and the time ? For example I do not want the
milliseconds to be shown.

BR
Thomas
Jul 20 '05 #1
1 7533


Thomas Mann wrote:

using XSLT 2.0 I can get a timestamp with the following line:
<xsl:value-of select="current-dateTime()"/>
How can I format the date and the time ? For example I do not want the
milliseconds to be shown.


Well, check the XPath 2.0 function reference, it shows a function
http://www.w3.org/TR/xslt20/#function-format-dateTime
format-dateTime that should allow you to format the result returned by
current-dateTime().
Here is an example, the second argument to format-dateTime is a string
with a so called picture which in my view would better be called
formatting pattern:

<xsl:template match="/">
<xsl:variable name="now" select="current-dateTime()" />
<root>
<result-unformatted><xsl:value-of select="$now" /></result-unformatted>
<result-formatted picture="[Y]-[M]-[D]">
<xsl:value-of select="format-dateTime($now, '[Y]-[M]-[D]')" />
</result-formatted>
<result-formatted picture="[Y]-[M]-[D]T[H]:[m]:[s]">
<xsl:value-of select="format-dateTime($now,
'[Y]-[M]-[D]T[H]:[m]:[s]')" />
</result-formatted>
</root>
</xsl:template>

An example output here on my machine with Saxon 8.1.1 is

<?xml version="1.0" encoding="UTF-8"?>
<root>
<result-unformatted>2004-10-14T12:27:39.921+02:00</result-unformatted>
<result-formatted picture="[Y]-[M]-[D]">2004-10-14</result-formatted>
<result-formatted
picture="[Y]-[M]-[D]T[H]:[m]:[s]">2004-10-14T12:27:39</result-formatted>
</root>
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: perplexed | last post by:
How do you convert a user inputted date to a unix timestamp before insterting it into your database? I have a form, with a textfield for a date that the user inputs in the format mm-dd-yyyy and...
2
by: Astra | last post by:
Hi All I know an SQL Server timestamp seems to be as useful as rocking horse for show jumping, but I'm hoping you know a 'fudge' to get me round a problem or at least confirm that it isn't...
2
by: rong.guo | last post by:
Hello Group, I am having a really weird problem... Can anyone tell the difference between Query 1 and Query 2 below? Why Query 2 excludes '2/28/2005'? Many thanks! create table a...
7
by: mybappy | last post by:
Hi: I am trying to use timestamp field of SQL Server to maintain concurrency. My problem is how do I store the timestamp value in my webform. The hidden field does not work as I get some cast...
2
by: Zygo Blaxell | last post by:
I have a table with a few million rows of temperature data keyed by timestamp. I want to group these rows by timestamp intervals (e.g. every 32 seconds), compute aggregate functions on the...
5
by: Prabu Subroto | last post by:
Dear my friends... I created some tables with field timestamp (datatype also timestamp). I mean, I want to have the data when each record inserted or modified in the tables. on MysQL, I just...
2
by: Russell Smith | last post by:
Timestamps support infinity. However if appears dates do not. When timestamps are cast to dates, there is no output. Is this an acceptable option or not? Below are a number of examples...
2
by: Reddog | last post by:
Hi all, I have a number of tables that I want 'timestamped' with both a modified and created 'timestamp' field. Ideally both fields should 'work if ignored' in insert and updates, thus the...
22
by: Mal Ball | last post by:
I hope I have the right forum for this question. I have an existing Windows application which uses a SQL Server database and stored procedures. I am now developing a web application to use the same...
7
by: JJ | last post by:
How do I set one field to have the updated timestamp, and another to have the created timestamp? I want to do this directly from code generated from DB Designer if possible?! JJ
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.