user5844: Im using the time module in the ledger class to do some custom validation logic, but everything is done as intervals and I cant find the function that gets the current time. What is it?

user6763: each transaction on Cardano has a ttl (Time To Live) determined in the moment of transaction creation, it can't be submitted outside that interval, and even if the transaction is submited, other node would not reconize it

on cardano-cli the ttl defaults to ~2/~3 hours after the tx-body creation

and this information is reported in the ScriptContext from the Plutus.V1.Ledger.Contexts module, in particular yo need the TxInfos and from then the POSIXTimeRange you get form the txInfoValidRange function.
so starting from the ScriptContext your function would be somehting like:
getTTL :: ScritpContext -> POSIXTimeRange
getTTL = txInfoValidRange . scriptContextTxInfo

If you need to express logic valid before a specific time you should check for the upper limit of the interval to be before that timestamp
since POSIXTimeRange is just an alias for Interval POSIXTime
type POSIXTimeRange = Interval POSIXTime

you can check the Interval documentation for more
but you can get the upper limit of the interval like so
extractFiniteUpper :: Interval a -> Maybe a
extractFiniteUpper interval = case ivTo interval of
    UpperBound (Finite value) _isInclusive -> Just value
    _ -> Nothing



5844: <p>Im using the time module in the ledger class to do some custom validation logic, but everything is done as intervals and I cant find the function that gets the current time. What is it?</p>
 6763: <p>each transaction on Cardano has a ttl (Time To Live) determined in the moment of transaction creation, it can't be submitted outside that interval, and even if the transaction is submited, other node would not reconize it</p>
<blockquote>
<p>on <code>cardano-cli</code> the ttl defaults to ~2/~3 hours after the tx-body creation</p>
</blockquote>
<p>and this information is reported in the <code>ScriptContext</code> from the <code>Plutus.V1.Ledger.Contexts</code> module, in particular yo need the <code>TxInfo</code>s and from then the <code>POSIXTimeRange</code> you get form the <code>txInfoValidRange</code> function.</p>
<p>so starting from the <code>ScriptContext</code> your function would be somehting like:</p>
<pre><code>getTTL :: ScritpContext -&gt; POSIXTimeRange
getTTL = txInfoValidRange . scriptContextTxInfo
</code></pre>
<p>If you need to express logic valid before a specific time you should check for the upper limit of the interval to be before that timestamp
since <code>POSIXTimeRange</code> is just an alias for <code>Interval POSIXTime</code></p>
<pre><code>type POSIXTimeRange = Interval POSIXTime
</code></pre>
<p>you can check <a href="https://playground.plutus.iohkdev.io/doc/haddock/plutus-ledger-api/html/Plutus-V1-Ledger-Interval.html#t:Interval" rel="nofollow noreferrer">the <code>Interval</code> documentation</a> for more</p>
<p>but you can get the upper limit of the interval like so</p>
<pre><code>extractFiniteUpper :: Interval a -&gt; Maybe a
extractFiniteUpper interval = case ivTo interval of
    UpperBound (Finite value) _isInclusive -&gt; Just value
    _ -&gt; Nothing

</code></pre>
