Just wanting to know if there is a better way to get a datetime in this way.
MM-DD-YYYY hh:mm:ss with leading zeros on the minute and second and 24 hour format?
Just wanting to know if there is a better way to get a datetime in this way.
MM-DD-YYYY hh:mm:ss with leading zeros on the minute and second and 24 hour format?
I think you want the format text node. Here is a thread that shows that:
I tried this but it still left out the leading zeros.
The issues i am finding is the time is returning this way from the engine when using the NOW node. I am formatting that.
Sorry, I made an false assumption about the Format Text node. It doesn’t have a comprehensive formatting capability for ints and floats as I assumed it would. Hopefully someone else knows the answer on this.
I set up something similar to what you have only using the Len Node. Since this creates an overly complex set of statements, there may be something you could by putting the leading zero add on into a function. All that would do is clean up the code but not improve it in a meaningful way. The function would take in a 1 or 2 digit int and return a 2 digit string. That doesn’t really buy you anything, you’d still need 5 calls to it for each value (mm, dd, hh, mm, ss).
Edit: I dummied the other concept up just to see if it could be fewer nodes than your method. Here it is, and no, it’s not better, just different.
I like the use of length, very nice.
I only wrote my method above to make it easy to understand my goal. it does not even take timing or latency on nodes into account and will possibly fail eventually lol.
I was just hoping their was a cheat sheet of codes like
MM-DD-YYYY hh:mm:ss
Or, you could make it super simple and just use this node. Convert a number of seconds into minutes:seconds.milliseconds format string (including leading zeroes).
Or use the To Text (Integer) node and enter the number of minimum integral digits. If your input has fewer digits it will add leading zeros. I put it in a macro.
ok