I have a number 1576742379172. I want to input this to get the output as Date and Time. Please help.
Discussion posts and replies are publicly visible
Can you explain what the number actually represents? For example, it could be the number of seconds since 1/1/1900 (I don't think it is, a quick calculation suggests not). But without an understanding of what it represents no-one can even begin to provide any help.
unix epoch time in milliseconds
Ok, so I think it'll something like this:
local!baseDate + (local!epochTime / (1000*60*60*24))
Inputting the value you provided (1576742379172) returns 12/19/2019 7:59 AM GMT+00:00 (you'll have to tell me if you think that's the correct datetime value)
The principle here is that I've taken the value you provided, divided by 1000 (because it's milliseconds) and then divided by 60 (to get minutes), then 60 again (to get hours) and then 24 (to get days) and then simply added those days to the base of 1/1/1970
Thank you Stewart. Its working.
You might want to 'harden' the above code (as a principle we shouldn't allow 'magic numbers' or 'literals' in code, so perhaps put the baseDate and the calculation values in constants so they can be managed separately from the code, and also makes the code readable.
we tried same logic with value 1614060146848 but it's returning infinite date time.
Works for me:
Are you using an Integer for the epochTime? If so you'll need to make that a decimal.
© 2022 Appian. All rights reserved.