A UNIX timestamp is number of seconds since 1/1/1970 so if you used the dateAdd method in umbraco:library to add 1250163047 seconds to 1/1/1970 you would get the correct date object returned and you could format as usual.
OK Tim did solve it on earlier with the original date format of 01/01/1970 and it was me being dumb with my XPath Selector. I should have done date/@uts and NOT date[@uts]
Trying to format UTS date format with umbraco.library:FormatDateTime()
Hello I was wondering if someone could help me trying to format a UTS date with the XSLT extension umbraco.library:FormatDateTime.
UTS (Unix Time Stamp) Date = 1250163047
Actual Date = 13 Aug 2009, 11:30
Some info on Unix Time Stamp
http://www.onlineconversion.com/unix_time.htm
http://en.wikipedia.org/wiki/Unix_time
I have no idea on how I could handle this problem any suggestions please.
Thanks,
Warren :)
A UNIX timestamp is number of seconds since 1/1/1970 so if you used the dateAdd method in umbraco:library to add 1250163047 seconds to 1/1/1970 you would get the correct date object returned and you could format as usual.
T
I think you'll need some .net code to make the conversion BEFORE using it in xslt.
http://codeclimber.net.nz/archive/2007/07/10/convert-a-unix-timestamp-to-a-.net-datetime.aspx
and here is another one http://www.codeproject.com/KB/cs/timestamp.aspx
>Tommy
OK excellent thanks guys, I will write this as an XSLT extension.
Warren :)
I think this will work in XSLT, not tested:
<xsl:value-of="umbraco.library:FormatDateTime(umbraco.library:DateAdd('1/1/1970','s', 1250163047), 'MMMM d, yyyy')" />
T
Tim, I tried it but it didn't work.
Does the 1970 date need to be in a different format?
Might need to be like this:
1970-01-01T00:00:00
T
Example:
<xsl:value-of="umbraco.library:FormatDateTime(umbraco.library:DateAdd('1970-01-01T00:00:000','s', 1250163047), 'MMMM d, yyyy')" />
Again not tested - just coding off the top of my head!
T
OK Tim did solve it on earlier with the original date format of 01/01/1970 and it was me being dumb with my XPath Selector.
I should have done date/@uts and NOT date[@uts]
is working on a reply...