Page 1 of 1

Convert timestampt to date/time?

PostPosted: Sun Apr 08, 2018 9:30 am
by howartp
Hi C4W.

Just thought I'd use this to convert a Unix timestamp to a visual date, purely for something I'm debugging in one of my own plugins - when I noticed that's not one of the options?

(Unless, there's a %code for the full timestamp but I can't find one?)

Peter

Re: Convert timestampt to date/time?

PostPosted: Sun Apr 08, 2018 9:33 am
by Colorado4Wheeler
Well, the date format is Python but it's just reading a string, so as long as you specify the format, in Python notation, it should covert.

Re: Convert timestampt to date/time?

PostPosted: Sun Apr 08, 2018 9:37 am
by howartp
But that’s the problem, there is no date notation for time.time() that strftime() etc supports?

If I’d used time.strftime(%y %m %d, time.time()) when creating my plugin then I could use your plugin to convert %y %m %d to something else.

But I used time.time() in my plugin, purely for counting seconds elapsed, so I didn’t need to format it in the plugin when I stored it in a state.

Now I want to temporarily (without recoding states) see the h:m:s value of that timestamp?


Sent from my iPhone using Tapatalk Pro

Re: Convert timestampt to date/time?

PostPosted: Sun Apr 08, 2018 9:52 am
by kw123
Code: Select all
time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
==> '2018-04-08 16:49:40'
Code: Select all
time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(time.time()))
==> '2018-04-08 15:50:19'

I am in the UK.. delta of 1 hour is due to DST

Karl

Re: Convert timestampt to date/time?

PostPosted: Sun Apr 08, 2018 9:54 am
by howartp
I know how to do it in code, I just thought it would a) be in the DE plugin already and b) because it isn’t, be a useful suggestion.

Seems not.


Sent from my iPhone using Tapatalk Pro

Re: Convert timestampt to date/time?

PostPosted: Sun Apr 08, 2018 10:36 am
by Colorado4Wheeler
howartp wrote:
I know how to do it in code, I just thought it would a) be in the DE plugin already and b) because it isn’t, be a useful suggestion.

It is and I'll look to add that. DE is a mess on my end right now with so many changes so you won't see that change for a while, that's why I was trying to see if there was a way to do it with what DE already does.

I didn't understand that you were wanting to drop to a shell to do it, I thought it was in Unix format and sitting somewhere in Indigo already, then it's a matter of converting the format.

Re: Convert timestampt to date/time?

PostPosted: Sun Apr 08, 2018 12:41 pm
by howartp
Colorado4Wheeler wrote:
howartp wrote:
I know how to do it in code, I just thought it would a) be in the DE plugin already and b) because it isn’t, be a useful suggestion.

It is and I'll look to add that. DE is a mess on my end right now with so many changes so you won't see that change for a while, that's why I was trying to see if there was a way to do it with what DE already does.

I didn't understand that you were wanting to drop to a shell to do it, I thought it was in Unix format and sitting somewhere in Indigo already, then it's a matter of converting the format.

Hehe, I don't want to drop to a shell, and it is in Unix format sitting in Indigo already...

Never mind, I've sorted my plugin issue anyway - it will be good to add to DE when you get to it but no urgency.