cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
956
Views
0
Helpful
3
Replies

get the current date

mr_cisco_cisco
Level 1
Level 1

I've seen some scripts where D[now] is used to get the current date. Is this considered best practice?

I'm wondering if it's better to use java.util.Date() instead, or if there is a better recommendation.  

3 Replies 3

I've never had issues with using either but one thing I have experienced is if you need a very specific format output the D[now] step isn't as flexible. It was a while ago that I dealt with that though so things may have changed or I may have just missed something.

How are you using the time variable?

Just to get the day of week and take action based on the day ie

switch int (D[now].dow)

I can't see where that would create any issues for you.

I think you could also easily use the "Day of Week" step under the general folder in the editor though. Might add some readability for the next guy.

Should be fine either way though.