Jump to content

Python Node Date and Time Comparison


Recommended Posts

Good Day!

So, I do search some raw python codes, but there are so many, but I can't find one that is specifically made for Cinema4D R14.


Do anyone know how to get the current device date and time and compare it with a time that I have set?

I do want to use it in making a Demo Version of a rig I was making, but since majority of it's parts do work under Python Scripts inside Xpresso tags, I think I can use that certain part of code to disable the main module that connects the parts to make the rig work at all.


Also, is there any way to print how many days remaining before the set datetime to arrive?

For example, I want to print "You have " + days + " days remaining before this rig set expires".


I can print it in console, but I don't know how it will be included in a string output

Link to post

Actually, nevermind. I just got it solved by my own.

But since it's here already, I'll share how to get days only to print in the string. You can also use some parts of it for logic script building.image.png.3c654e9ddc0749c56aca70284bc77fe4.png

import c4d
import datetime
#Welcome to the world of Python

def main():
    global Output1
    starttrial = datetime.date.today() # Date on your computer
    endtrial = datetime.date(2019,9,1) # Date on when it expires
    TimeComparison = endtrial - starttrial # Date comparison
    Output1 = "You only have " + (str(TimeComparison.days)) + " days before this rig expires..." #Print as String


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...