Advertisement
cd62131

datetime.xsl

Oct 7th, 2017
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 1.22 KB | None | 0 0
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <xsl:stylesheet
  3.  version="1.0"
  4.  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  5.  xmlns:date="http://exslt.org/dates-and-times"
  6.  extension-element-prefix="date">
  7.   <xsl:output method="html"/>
  8.   <xsl:template match="/">
  9.     <xsl:variable name="timestamp" select="1507387355"/>
  10.     <xsl:variable name="datetime"
  11.      select="date:add('1970-01-01T00:00:00+09:00',
  12.      date:add-duration(date:duration($timestamp),'PT9H'))"/>
  13.     <xsl:variable name="year" select="date:year($datetime)"/>
  14.     <xsl:variable name="month" select="date:month-in-year($datetime)"/>
  15.     <xsl:variable name="day" select="date:day-in-month($datetime)"/>
  16.     <xsl:variable name="hour" select="date:hour-in-day($datetime)"/>
  17.     <xsl:variable name="minute" select="date:minute-in-hour($datetime)"/>
  18.     <xsl:variable name="second" select="date:second-in-minute($datetime)"/>
  19.     <p><xsl:value-of select="$datetime"/></p>
  20.     <p><xsl:value-of select="$year"/></p>
  21.     <p><xsl:value-of select="$month"/></p>
  22.     <p><xsl:value-of select="$day"/></p>
  23.     <p><xsl:value-of select="$hour"/></p>
  24.     <p><xsl:value-of select="$minute"/></p>
  25.     <p><xsl:value-of select="$second"/></p>
  26.   </xsl:template>
  27. </xsl:stylesheet>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement