Jump to content
UBot Underground

Generate Random DateTime Between Two Dates (UNIX)


Recommended Posts

Didn't find anything on the forum about this yet, so hopefully this will be useful to anyone searching how to do it in the future. Was using javascript to generate random dates before, but like this way better as it doesn't need a webpage.

 

You will need the free datetime manipulation plugin created by UBotDev.com: http://www.ubotstudio.com/forum/index.php?/topic/13665-free-plugin-datetime-manipulation/

 

Thanks should go to UBotDev.com for creating and giving out this very handy plugin for free. :)

 

Example code below:
 

define $Random DateTime(#date start, #date end) {
    set(#date start unix, $plugin function("DateTime Manipulation.dll", "$datetime manipulation", #date start, "M/d/yyyy", "UNIX", "en-US", "en-US"), "Local")
    set(#date end unix, $plugin function("DateTime Manipulation.dll", "$datetime manipulation", #date end, "M/d/yyyy", "UNIX", "en-US", "en-US"), "Local")
    return($plugin function("DateTime Manipulation.dll", "$datetime manipulation", $rand(#date start unix, #date end unix), "UNIX", "yyyy-MM-dd HH:mm:ss", "en-US", "en-US"))
}
ui text box("Start Date (M/d/yyyy)", #date start)
ui text box("End Date (M/d/yyyy)", #date end)
loop(3) {
    alert($Random DateTime(#date start, #date end))
}


Input format set to: M/d/yyyy
Output format set to: yyyy-MM-dd HH:mm:ss

Change it up to your preferred formats of course.

 

Useful for scheduling a batch of blog posts to random dates, or other purposes.

  • Like 1
Link to post
Share on other sites

Join the conversation

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

Guest
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.

Loading...
×
×
  • Create New...