Find Date Difference in BrightScript

£可爱£侵袭症+ 提交于 2021-02-07 20:37:25

问题


I have an issue with datetime.

I have two strings. e.g 24-9-15 and 2-10-15. Both are two strings.

I want to find out the difference (in days) between them.

Can you please help me out?


回答1:


1) Parse the 2 strings to roDateTime objects.

Reference - http://sdkdocs.roku.com/display/sdkdoc/roDateTime

2) get the time in seconds for both dates by doing date1.AsSeconds() and date2.AsSeconds()

3) Subtract the 2 times, so you have the time difference in seconds.

4) Divide this seconds by 3600 to convert into hours, then divide by 24 to convert into days

ie. (seconds/3600) / 24




回答2:


date1 = CreateObject("roDateTime")
date2 = CreateObject("roDateTime")
diffInSeconds = date1.asSeconds() - date2.asSeconds()
print "seconds lapsed " diffInSeconds



回答3:


If those are your strings, I do not think there are any functions that will help you. You may have to do it manually. Still, you can look at the ifDateTime functions and see if they help.



来源:https://stackoverflow.com/questions/32753953/find-date-difference-in-brightscript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!