I want to capture the current local time (as "hh:mm:ss") into a temporary variable in a macro. I've tried the action "Set temporary Variable" with a value of {eg.event.time.strftime('%X %x %Z')} but just get an error. If I set the value to {eg.event.time} I DO get a numeric string like 100343.402617 but that's not what I want.
It'd be nice to find a list of possible values for xxx in {eg.event.xxx}
Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
How do I set a variable to current time?
Re: How do I set a variable to current time?
I usually use Python commands for getting the time. Here's an example you can try:
Code: Select all
import time; mytime = time.strftime("%H:%M:%S"); print mytimeThis info can be found here. However, many more values are available and you can find these in a little known section of EG. In the Help menu, select Python Shell. At the lower part of the window, look in the Namespace tab. Under eg.globals, expand eg then event and you'll find a large number of built-in eg.event.* variables.It'd be nice to find a list of possible values for xxx in {eg.event.xxx}
Re: How do I set a variable to current time?
Thanks! With your help, I created a temporary variable named "nowTime" in a Python Script like this:
Pretty good for a beginner, eh?!
But I wonder, couldn't it be done with the Set Temporary Variable action? I don't know enough about Python and how to work with it in EG. I was thinking I could use curly braces or something in the action value to use the calculation as opposed to writing a script which called the webserver function, but I couldn't get that to work.
Also thanks for the tip on the Python Shell!
Code: Select all
import time
eg.plugins.Webserver.SetValue(u'mailOTime', time.strftime("%H:%M:%S"), False, False)But I wonder, couldn't it be done with the Set Temporary Variable action? I don't know enough about Python and how to work with it in EG. I was thinking I could use curly braces or something in the action value to use the calculation as opposed to writing a script which called the webserver function, but I couldn't get that to work.
Also thanks for the tip on the Python Shell!
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: How do I set a variable to current time?
You can also do it this way:
Pako
You know flattr ? You can 
