Displaying Date as DD-MM-YYYY within XSLT/XML

前端 未结 4 1457
清酒与你
清酒与你 2021-01-21 19:18

Been trying to format the text to display as DD-MM-YYYY when pulled from XML to XSLT 1.0, since I know it has to be laid out as YYYY-MM-DD within XSD/XML when using xs:date whic

4条回答
  •  悲哀的现实
    2021-01-21 19:19

    I would use different solutions from those provided by @Stormtroopr for both 1.0 and 2.0.

    In 2.0 use

    format-date(xs:date($date), '[D01]-[M01]-[Y0001]')
    

    In 1.0 use

    concat(substring(., 9, 2), 
             '-', 
             substring(., 6, 2), 
             '-', 
             substring(., 1, 4))
    

    For future reference, please tell us which version of XSLT you are using. Both 1.0 and 2.0 are in common use, and the solutions are often different.

提交回复
热议问题