# Checking current time

**URL:** <https://in-thread.sonic-pi.net/t/checking-current-time/1551>\
**Category:** Support, Help & Resources\
**Created:** [October 8, 2018, 11:57pm UTC](https://in-thread.sonic-pi.net/t/checking-current-time/1551 "2018-10-08T23:57:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![buzz](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@buzz](https://in-thread.sonic-pi.net/u/buzz)\
**Post date:** [October 8, 2018, 11:58pm UTC](https://in-thread.sonic-pi.net/t/checking-current-time/1551/1 "2018-10-08T23:58:00Z")

</div>

Hi all,

I’d like to have Sonic Pi play something different based on the time of day (for example, if the time is between 12am and 1pm, play loop A, between 1pm and 2 pm, play loop B, etc). Is there a way to access the current date/time in sonic pi? Or alternatively, the time since sonic pi was launched?

Thanks for any help!!

---

<div class="post-metadata">

**Author:** ![samaaron](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/samaaron/32/7_2.png) [@samaaron](https://in-thread.sonic-pi.net/u/samaaron)\
**Post date:** [October 9, 2018, 8:53am UTC](https://in-thread.sonic-pi.net/t/checking-current-time/1551/2 "2018-10-09T08:53:55Z")

</div>

Hi there,

nice question. You can always access time with:

```ruby
Time.now

```

You can then convert that to a number to use as a random seed with:

```ruby
Time.now.to_i

```

Hope that this helps 🙂

---

<div class="post-metadata">

**Author:** ![synchron](https://avatars.discourse-cdn.com/v4/letter/s/58f4c7/32.png) [@synchron](https://in-thread.sonic-pi.net/u/synchron)\
**Post date:** [September 17, 2020, 7:42am UTC](https://in-thread.sonic-pi.net/t/checking-current-time/1551/3 "2020-09-17T07:42:24Z")

</div>

That is a great answer to question 1.  
The second question “time since sonic pi was launched” could be resolved by saving the launchtime in a variable and substract it from current time in each loop.

But i think time is here more a question of “beats”.  
And there i have no answer how to access the current “beattime”.  
It is printed out in the console  
{run: 1, time: 0.0}

How can i access this time?

---

<div class="post-metadata">

**Author:** ![ethancrawford](https://avatars.discourse-cdn.com/v4/letter/e/a88e4f/32.png) [@ethancrawford](https://in-thread.sonic-pi.net/u/ethancrawford)\
**Post date:** [September 17, 2020, 8:02am UTC](https://in-thread.sonic-pi.net/t/checking-current-time/1551/4 "2020-09-17T08:02:16Z")

</div>

Hi @synchron 🙂 There are two options for getting the beat time of the current thread/loop - `beat` and `vt`. (You can find these described in the `lang` help section).  
The difference between these is that `beat` does not have any concept of ‘rate’, while `vt` does.
