# Calculate with dates

**URL:** <https://community.homey.app/t/calculate-with-dates/107229>\
**Category:** Questions & Help\
**Created:** [March 28, 2024, 1:08am UTC](https://community.homey.app/t/calculate-with-dates/107229 "2024-03-28T01:08:43Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [March 28, 2024, 8:45pm UTC](https://community.homey.app/t/calculate-with-dates/107229/4 "2024-03-28T20:45:28Z")

</div>

Buckle up 🤪  
Some examples of calculating time, and converting time (from minutes to hours and v.v)

> [@\[APP\]\[Pro\] Better Logic Library - For Users](https://community.homey.app/t/app-pro-better-logic-library-for-users/71876/26):
>
> although again it’s a very nice flow from @Peter_Kawa , perhaps here is a somewhat simpler solution. Only issue is, it works with UTC (since Homey base time is always set to UTC/GMT). [image] new Date().setHours(18,0,0,0) - Date.now() \< 5\*60\*1000; This Condition Expression card will return true when the time is less then 5 minutes before 18u00utc.

> [@\[APP\]\[Pro\] Better Logic Library - For Users](https://community.homey.app/t/app-pro-better-logic-library-for-users/71876/28):
>
> Well, you can kind off, but not in the easy ‘formatting’ way: because i didn’t find a all-around solutions independend of locale and timezone. date('DATETIME', null, 'en') You will get a tag, you can use the last number if it’s like this. But if you get this, you will probably get the same result as me: So, the complete solution would be: new Date().setHours(18-Number.parseInt(\_.last(date('DATETIME', null, 'en'))),0,0,0) - Date.now() \< 15\*60\*1000; (this is true when less the…

> [@\[APP\]\[Pro\] Better Logic Library - For Users](https://community.homey.app/t/app-pro-better-logic-library-for-users/71876/30):
>
> This is guru level crazy_face I only missed the minutes part of the targeted time, a first wild guess seems to work for 'is true when less than 15 minutes before 18.30h: new Date().setHours(18-Number.parseInt(\_.last(date('DATETIME', null, 'en'))),30,0,0) - Date.now() \< 15\*60\*1000;

> [@\[APP\]\[Pro\] Better Logic Library - For Users](https://community.homey.app/t/app-pro-better-logic-library-for-users/71876/100):
>
> I share here the power of the BLL card “Set variable to text”.
> 
> ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/5/0/506c6a2409081288accc267b24b7f3ab5a9aa411.png)
> 
> This means you can add one or more texts and BLL expressions into any text variable, pass the variable to a central flow where you process it with a single BLL card.
> 
> This saves (me) several formatting cards in various flows.

---

_[View the full topic](https://community.homey.app/t/calculate-with-dates/107229)._
