Jump to content
UBot Underground

Add Time To Date


Recommended Posts

i want to add the string in the variable seconds to the date and get the new date/timestamp

set(#dt, $date, "Global")
set(#seconds, "00:15:08", "Global")
set(#diff, $add(#dt, #seconds), "Global")

but its not working. it just attaches it to end of the dt e.g and gives something like

 #diff: 01/12/2016 00:37:1800:15:08
Link to post
Share on other sites

Your best option is to use this plugin: http://ubotdev.com/free-plugin-datetime-manipualtion

 

Then convert the time into a unix timestamp, then add only the number of seconds so if its 15 minutes 8 seconds you would add 908 to the unix timestamp.

Then you can do anything with that timestamp as it represents a date and time you can read about what exactly that is here: http://www.unixtimestamp.com/

 

Doing this would give you a time of 15 minutes and 8 seconds into the future and solve all the little problems of factoring in minutes, hours, days of the month, year and so on that you would run into if it were say Feb 28th, 11:58 PM on a leap year or something - too many weird little things to account for without doing it this way.

 

Here is a bit of code that shows how to do that:

set(#dt,$plugin function("DateTime Manipulation.dll", "$datetime manipulation", $date, "UBOT", "UNIX", "en-US", "en-US"),"Global")
set(#seconds,908,"Global")
set(#diff,$add(#dt,#seconds),"Global")
alert("new time: {$plugin function("DateTime Manipulation.dll", "$datetime manipulation", #diff, "UNIX", "UBOT", "en-US", "en-US")}")
  • 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...