Reputation: 13
How could I insert a current date and time into a specified location? For example, somewhere in a text or a column in a table. In addition, the result would be a group which cannot be modified.
I use the following string on a button as I click it but it only works on the specified textbox in a form I create. I want the date and time to be freely inserted at anywhere I specify.
import datetime
aaa=datetime.datetime.now().strftime ("%Y-%m-%d %H:%M:%S")
ActiveForm.Controls["GroupBox1"].Controls["TextBox4"].Text = aaa
Upvotes: 0
Views: 668
Reputation: 2253
you could see the official doc to learn more.
>>> import time
>>> time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
'2017-06-30 11:55:12'
>>> type(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()))
<type 'str'>
>>>
Upvotes: 1