Convert (UNIX-)Timestamp
Convert (UNIX-)Timestamp
Hello,
is there a way to convert a (Unix)Timestamp like 170255541600 in a report to an readable Format?
Thanks
is there a way to convert a (Unix)Timestamp like 170255541600 in a report to an readable Format?
Thanks
-
- Posts: 6680
- Joined: Tue Mar 20, 2018 5:34 am
Re: Convert (UNIX-)Timestamp
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.
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.
- Attachments
-
- Screenshot 2024-01-17 025330.png (87.41 KiB) Viewed 3357 times
Re: Convert (UNIX-)Timestamp
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.
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.
-
- Posts: 6680
- Joined: Tue Mar 20, 2018 5:34 am
Re: Convert (UNIX-)Timestamp
Hello,
You can add your own function in the report Dictionary:
https://www.stimulsoft.com/en/documenta ... ctions.htm
Thank you.
You can add your own function in the report Dictionary:
https://www.stimulsoft.com/en/documenta ... ctions.htm
Thank you.
Re: Convert (UNIX-)Timestamp
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?
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?
-
- Posts: 6680
- Joined: Tue Mar 20, 2018 5:34 am
Re: Convert (UNIX-)Timestamp
Hello,
DId you add your own function and this function is not working in the viewer?
Thank you.
DId you add your own function and this function is not working in the viewer?
Thank you.
Re: Convert (UNIX-)Timestamp
Yes, this is the code integrated in the server.js file:
Thank you.
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);
-
- Posts: 6680
- Joined: Tue Mar 20, 2018 5:34 am
Re: Convert (UNIX-)Timestamp
Hello,
We couldn't reproduce the issue.
Please send us a sample project that reproduces the issue for analysis.
Thank you.
We couldn't reproduce the issue.
Please send us a sample project that reproduces the issue for analysis.
Thank you.