Page 1 of 1
Convert (UNIX-)Timestamp
Posted: Thu Jan 18, 2024 8:55 am
by hydrant
Hello,
is there a way to convert a (Unix)Timestamp like 170255541600 in a report to an readable Format?
Thanks
Re: Convert (UNIX-)Timestamp
Posted: Thu Jan 18, 2024 5:07 pm
by Lech Kulikowski
Hello,
In the Compilation mode (CalculationMode property), you can use the FromUnixTimeSeconds method:
{DateTimeOffset.FromUnixTimeSeconds(170255541600)}
https://learn.microsoft.com/en-us/dotne ... tem_Int64_
Thank you.
Re: Convert (UNIX-)Timestamp
Posted: Fri Apr 05, 2024 1:17 pm
by aletopo
Hi there,
It seems this way of conversion uses .NET framework methods. It works fine when generating a single report from desktop application, but fails in batch processing (fields remain empty).
For batch processing we are using a Node.js based server. I assume all .NET framefork methods like DateTimeOffset.FromUnixTimeSeconds() don't work this way.
Any easy alternatives known or any suggestions?
Thank you in advance.
Re: Convert (UNIX-)Timestamp
Posted: Sun Apr 07, 2024 7:14 pm
by Lech Kulikowski
Hello,
You can add your own function in the report Dictionary:
https://www.stimulsoft.com/en/documenta ... ctions.htm
Thank you.
Re: Convert (UNIX-)Timestamp
Posted: Fri Apr 12, 2024 1:38 pm
by aletopo
Hello,
Thank you, this was the decisive hint and it works when sending a request to the reporting server
Unfortunately the stimulsoft.viewer still fails to recognize the function. Eventually some more configuration needed?
Re: Convert (UNIX-)Timestamp
Posted: Fri Apr 12, 2024 3:10 pm
by Lech Kulikowski
Hello,
DId you add your own function and this function is not working in the viewer?
Thank you.
Re: Convert (UNIX-)Timestamp
Posted: Tue Apr 16, 2024 6:07 am
by aletopo
Yes, this is the code integrated in the server.js file:
Code: Select all
function unixToISO(timestamp) {
iso = new Date(timestamp).toISOString();
return iso;
};
Stimulsoft.Report.Dictionary.StiFunctions.addFunction("Unix", "unixToISO", "unixToISO", "Description", "", String, "", [Number], ["timestamp"], [""], unixToISO);
Thank you.
Re: Convert (UNIX-)Timestamp
Posted: Wed Apr 17, 2024 8:55 pm
by Lech Kulikowski
Hello,
We couldn't reproduce the issue.
Please send us a sample project that reproduces the issue for analysis.
Thank you.