How to save current date and time?

Hi, I’m trying to create a JSON file with the values of the parameters set by the user and I’d like to save also current date and time. In the attached picture there is the definition that I tried but “Component Timer may not be used” by ShapeDiver.
Any suggestion to overcome this limitation?
Thank you in advance!

I’d start with this?

date_time

Oh, wait… Time is fixed to the moment you first put it on the canvas and doesn’t change. Kind of useless, isn’t it. :frowning:

Here’s a Python thing; every time you push the button (or otherwise trigger the ‘x’ input?), the date/time updates:

import datetime
now = datetime.datetime.now()
Y = now.year
M = now.month
D = now.day
h = now.hour
m = now.minute
s = now.second


time_date_2019Jul8a.gh (5.5 KB)

2 Likes

Thank you Joseph!
Now it makes sense and it is working!

Please note that this is not a perfect solution because ShapeDiver caches solutions that were already computed from the online model. Therefore the same set of parameters will pull the cached version and the previously computed time, not the current one.
If you want to prevent this, you can add a ‘seed’ parameter and give it a new random value every time you export the JSON file. You could hide this parameter from the users and set a new value using the API before exporting the file. Another way would be to ask users to enter their name or other text (using ShapeDiverTextInput), which would generate a unique parameter set every time.