XSLT 格式日期 [英] XSLT Format Date

查看:36
本文介绍了XSLT 格式日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这种格式的日期

I have a date in this format

10/12/2011 12:55:00 PM (MM-DD-YYYY time)

我想将此日期格式化为

12/10/2011 (DD-MM-YYYY) time to be removed 

使用 XSLT?我发现的复杂性有时是输入日期可能看起来像

using XSLT? the complexity I find is sometimes the input date can look like

7/12/2011 12:55:00 PM (only one number to the front instead of 07)

有人可以告诉我一种实现方法吗?提前谢谢了.

Can someone please show me a way to implement this? many thanks in advance.

推荐答案

仅使用标准的 XPath 字符串函数(例如 substring-beforesubstring-aftersubstring,例如:

It is easy to obtain desired result using only standard XPath string functions like substring-before, substring-after and substring, e.g.:

<xsl:variable name="input">7/12/2011 12:55:00 PM</xsl:variable>

<xsl:value-of select="concat(
              substring-before(substring-after($input, '/'), '/'), '/',
              substring-before($input, '/'), '/',
              substring(substring-after(substring-after($input, '/'), '/'), 1, 4)
              )"/>

这篇关于XSLT 格式日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆