dateTime to Epoch and vice versa xslt

前端 未结 2 1508
挽巷
挽巷 2021-01-19 12:01

I have been trying to convert a given dateTime to epoch time and also a given epoch time to dateTime. I am quite new to xslt and have been struggling with this quite for som

2条回答
  •  终归单人心
    2021-01-19 12:39

    If you are trying to do this in XSLT 1.0 on MSXML (I know the original asker is not):

    
      
      
        
      
      
    
    

    Replace the '1970-01-02' with whatever text node you want and this should work, as long as that node was a valid date time. If not, it's easy enough to write up another simple method to do that using DateTime.Parse/TryParse. The output of this template (against any valid XML) would be 86400. Note that it's best to define methods in a CDATA node to avoid needing to escape quotes or angle brackets (this code doesn't happen to use any but might be extended to for some reason).

提交回复
热议问题