# Error on getTime

**URL:** <https://forum.canton.network/t/error-on-gettime/4783>\
**Category:** App Development\
**Tags:** daml\
**Created:** [June 23, 2022, 2:29pm UTC](https://forum.canton.network/t/error-on-gettime/4783 "2022-06-23T14:29:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![h\_twist](https://avatars.discourse-cdn.com/v4/letter/h/85e7bf/32.png) [@h\_twist](https://forum.canton.network/u/h_twist)\
**Post date:** [June 23, 2022, 2:29pm UTC](https://forum.canton.network/t/error-on-gettime/4783/1 "2022-06-23T14:29:09Z")

</div>

I have an application that consists of two main components a Web browser and a mobile app.

Those two interact with the DAML ledger via the exact same API.

The problem I have now is because when one of the choices is performed by the mobile app, it throws an error FAILED\_PRECONDITION: DAML\_INTERPRETATION\_ERROR, the error message thrown matches the following part on the DAML model:

> now ← getTime  
> assertMsg “Outside time window” $contract.startTime \<= now \<= contract.endTime

I tried to set a large time window of 1900 - 2100 and the error persisted.  
Additionally, previous steps have the same logic but are working properly on both the browser and the mobile app.

Does anyone know what could be the cause of this problem?

---

<div class="post-metadata">

**Author:** ![cocreature](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/cocreature/32/36_2.png) [@cocreature](https://forum.canton.network/u/cocreature)\
**Post date:** [June 24, 2022, 10:05am UTC](https://forum.canton.network/t/error-on-gettime/4783/2 "2022-06-24T10:05:28Z")

</div>

Can you include `contract.startTime`, `contract.endTime` and `now` and share the values once you get the error?

One option may be a timezone thing: Daml ledger time is in UTC. If you set some time on the client side, maybe your mobile app uses local time or something like that.

---

<div class="post-metadata">

**Author:** ![h\_twist](https://avatars.discourse-cdn.com/v4/letter/h/85e7bf/32.png) [@h\_twist](https://forum.canton.network/u/h_twist)\
**Post date:** [June 27, 2022, 10:37am UTC](https://forum.canton.network/t/error-on-gettime/4783/3 "2022-06-27T10:37:00Z")

</div>

thanks for your reply. How do you recommend doing this? I tried `assertMsg “Outside time window” <> show now $contract.startTime <= now <= contract.endTime`  
But I could not even build the model with this code, I searched for other possibilities but nothing seemed to work on how to cope with this problem ☹ .

---

<div class="post-metadata">

**Author:** ![cocreature](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/cocreature/32/36_2.png) [@cocreature](https://forum.canton.network/u/cocreature)\
**Post date:** [June 27, 2022, 10:41am UTC](https://forum.canton.network/t/error-on-gettime/4783/4 "2022-06-27T10:41:50Z")

</div>

`assertMsg` takes two arguments. The first is the text used if the assertion fails, the second is the boolean you want to test. So in your example, something like this should work:

```haskell
assertMsg
  ("Current time " <> show now <> 
   " is outside time window " <> show (contract.starteTime, contract.endTime)) 
  (contract.startTime <= now && now <= contract.endTime)

```

---

<div class="post-metadata">

**Author:** ![h\_twist](https://avatars.discourse-cdn.com/v4/letter/h/85e7bf/32.png) [@h\_twist](https://forum.canton.network/u/h_twist)\
**Post date:** [June 28, 2022, 12:46pm UTC](https://forum.canton.network/t/error-on-gettime/4783/5 "2022-06-28T12:46:16Z")

</div>

This meant to output the error data, but turned out to be the solution for fixing the code 😉
