Live update Date and Time?

To Acquire the Date and Time, as of now I need to hit the button to show the time, is it possible to have the time run live so I don’t need to hit the button to update?

may be like this?

Live date and (4.9 KB)

If you didn’t get what you really need by then, ask me on Tuesday here (when I’m back at my office)
I’ve got a small c# component that does just that and refreshes on its own.

again inspired by @antoinemaesantoine
like this?

Ugly, but its friday and I am lazy:

1 Like

I think you want to call expire solution with a time step…
reference code here

It was something like this :

  private void RunScript(ref object D, ref object Y, ref object M, ref object D, ref object h, ref object m, ref object s)

    now = DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss");

    String[] dateList = now.Split((char) 32);
    string YMD = dateList[0];
    string hms = dateList[1];
    String[] YMDList = YMD.Split((char) 47);
    String[] hmsList = hms.Split((char) 58);
    Date = now;
    Y = YMDList[2];
    M = YMDList[0];
    D = YMDList[1];
    h = hmsList[0];
    m = hmsList[1];
    s = hmsList[2];
    GrasshopperDocument.ScheduleSolution(1000, ScheduleSolutionCallback);

  // <Custom additional code> 

  string now;

  public void ScheduleSolutionCallback(GH_Document doc)

  // </Custom additional code> 
} (5.7 KB)

Keep in mind that every second, Grasshopper thinks you’ve modified the definition.
You’ll pretty much have the small " * " on the top left, next to the name of your file :slight_smile:


I use a small Python script for that. It’s literally one line and you can output any format you like:

Just go to the cheat sheet for the strftime function for Python and you can assemble any date you like.

Then you either leave it without a trigger and it will update on every recompute (good for example for automatic file names) or you attach a trigger. (5.1 KB)

1 Like


Just noticed you can even have a spread as an input and get a spread back out. Neat:

Interesting !

Here would be a version without the trigger
I’ve also added a “expire” input in case you want to stop the refresh (default is True)

from datetime import datetime

def schedule_solution_callback(doc):

if e == None:
    e = True

doc = ghenv.Component.OnPingDocument()
d =

if e:
    doc.ScheduleSolution(1000, schedule_solution_callback) (5.7 KB)

1 Like

Awesome thanks. I’ll replace it in my growing collection of user objects with this updated version :slight_smile:

I didn’t knew you can format in the tostring method. Nice!

@sajesh_pj Awesome! Thank You!!

1 Like

A component based on @antoinemaesantoine script

CurrentTime.gha (8.5 KB)