0

unix time stamp

Fabien Fuster 6 years ago in General updated by Ricardo Pinto | visiontech pt 6 years ago 5

Hello,


Grabing some info via API for various application, I need to decode UNIX time stamp.


Despite extensive search on the net, I could not find a way to program a decoding way in bOS so far. Any idea how to do this ?


Thanks in advance for any help,

Hi Fabien,


Maybe there's a better way to do this, but if it's not straightforward in bOS, my suggestion is:


- Get the UNIX timestamp with bOS

- Use Http on bOS to post the value to an online converter API, like http://www.convert-unix-time.com/api

- Extract the data from the converter API in the correct format


It's not a straightforward / neat solution, but...


Never used the converter above, you can check others.


Best regards,

Ricardo Pinto

Thanks Ricardo,


Will have a look into it and try to get it working. Will feedback when possible.


Regards,

Fabien

Hi Fabien,


I've tested the link I've sent...


I don't know what you need to do with the returned data, but I can tell you that it returns a string with the current date and time based on the UNIX timestamp. So if it's for just visualization purposes, I think that it works perfectly. Otherwise, maybe you should try looking for other API that can return single data, like year, hour, minute etc.


If you want to test it, here it goes: Casa-UNIX timestamp.bos

Basically it executes a GET to the url http://www.convert-unix-time.com/api?timestamp=now every 10s and then extracts the current date and time to a string.


If you are not confident about the unix timestamp on the link, you can submit your own timestamp value to the online converter and extract back the date and time with http://www.convert-unix-time.com/api?timestamp=X
You need to change X to the UNIX timestamp you want to convert back.


You need to add the Value in the visualization.


Regards

Hi Ricardo,


Thanks for your time. I was already creating the device...


I've tested it extensively and it works great. However, my main issue with it is that I cannot grab single value back (such as day only, or day only, etc...).

I then spent quite some time on the net again, hoping to find alternate API solution but so far  I was unsuccessfull. I will look further, but should you (or anyone else) have a link to share, feel free ;-).


Thanks again for your time and help,

Fabien

Hi Fabien,


Yeah, you got the same problem as I did, it's not possible to extract single data... :-/


Not sure if it's the only API available, I hope not. If I find an alternative, I'll post it.


You're welcome, glad I can help. I'm quite surprised to see that someone actually recognizes when other users spend some time helping others (yep, not everyone here is from Comfortclick support!). Most of us here, are actually competitors, even if we're from different countries. But most of the people here come just for quick solutions, and don't even mind searching a little bit, try things out, read some articles or some examples over the internet, or most important, share.


So a simple "Thanks" is actually more than welcome.


Glad to share.

Ricardo