Jump to content
UBot Underground

How Do I Subtract Two Time Stamps To Get A Number Of Days


Recommended Posts

How do I subtract date1 - date2 = xdays?

 

date1 = 2017-06-26 00:00:00

date2 = 2017-06-25 00:00:00

 

If I subtract date1 - date2 it should be one day.

 

Thanks

 

Typically with time you want to convert it to unix time and then work with it in this case you can convert it, subtract to get the difference and then divide that by 86400 (one day in seconds).

 

You can use this plugin: http://ubotdev.com/free-plugin-datetime-manipualtion

 

This will basically do that and round it using the ubot round function (which rounds to 2 places) if you want to a whole number you can use javascript.

set(#date1,$plugin function("DateTime Manipulation.dll", "$datetime manipulation", "2017-06-26 00:00:00", "yyyy-MM-dd HH:mm:ss", "UNIX", "en-US", "en-US"),"Global")
set(#date2,$plugin function("DateTime Manipulation.dll", "$datetime manipulation", "2017-06-25 00:00:00", "yyyy-MM-dd HH:mm:ss", "UNIX", "en-US", "en-US"),"Global")
set(#differenceInSeconds,$absolute value($subtract(#date1,#date2)),"Global")
set(#difference,$round($divide(#differenceInSeconds,86400)),"Global")
  • Like 2
Link to post
Share on other sites

 

Typically with time you want to convert it to unix time and then work with it in this case you can convert it, subtract to get the difference and then divide that by 86400 (one day in seconds).

 

You can use this plugin: http://ubotdev.com/free-plugin-datetime-manipualtion

 

This will basically do that and round it using the ubot round function (which rounds to 2 places) if you want to a whole number you can use javascript.

set(#date1,$plugin function("DateTime Manipulation.dll", "$datetime manipulation", "2017-06-26 00:00:00", "yyyy-MM-dd HH:mm:ss", "UNIX", "en-US", "en-US"),"Global")
set(#date2,$plugin function("DateTime Manipulation.dll", "$datetime manipulation", "2017-06-25 00:00:00", "yyyy-MM-dd HH:mm:ss", "UNIX", "en-US", "en-US"),"Global")
set(#differenceInSeconds,$absolute value($subtract(#date1,#date2)),"Global")
set(#difference,$round($divide(#differenceInSeconds,86400)),"Global")

 

 

Dude your the best.  Hopefully Irma was good to you :)  Thanks.

  • Like 1
Link to post
Share on other sites
  • 3 years later...
On 10/10/2017 at 11:36 PM, HelloInsomnia said:

Hello, i have updated ubot to 6.3.9 and lost all my free plugins.

This link is not valid anymore;

By any chance is there a link for free plugins?

Thanks in advanced!

Edit : nvm im really a dumb! just seen im in plugins section! shame on me. Sorry

Edited by kill3rbko
Im a dumb
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...