# Is it possible to have script to get 'system time' - UTC or GMT?

**URL:** https://community.glideapps.com/t/is-it-possible-to-have-script-to-get-system-time-utc-or-gmt/29739
**Category:** Ask for Help
**Tags:** custom-code
**Created:** [July 30, 2021, 8:46am UTC](https://community.glideapps.com/t/is-it-possible-to-have-script-to-get-system-time-utc-or-gmt/29739 "2021-07-30T08:46:12Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![Mark\_Turrell](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mark_turrell/32/26605_2.png) [@Mark\_Turrell](https://community.glideapps.com/u/Mark_Turrell)
#### Post date: [July 30, 2021, 8:46am UTC](https://community.glideapps.com/t/is-it-possible-to-have-script-to-get-system-time-utc-or-gmt/29739/1 "2021-07-30T08:46:12Z")

</div>

I have a need to get a time value that is set by the outside world, and not the user’s device. For instance, I now have people doing corona tests with my app around the world (good), but we have opening hours of 12-19 CET during this pilot phase. BUT Glide uses the user’s device to work out ‘now’ so I am getting all kinds of problems.

I know I have asked this of @Mark before… but it occurs to me that this might be a relatively easy thing for yes-code, something that could be useful for lots of apps. A script that pulls in the common time… and then once it is in Glide, magic can happen 🙂  
Thanks!

---

<div class="post-metadata">

### Author: ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)
#### Post date: [July 30, 2021, 8:59am UTC](https://community.glideapps.com/t/is-it-possible-to-have-script-to-get-system-time-utc-or-gmt/29739/2 "2021-07-30T08:59:04Z")

</div>

> [@clock3 System/GMT Time - Solved!](https://community.glideapps.com/t/system-gmt-time-solved/27524/):
>
> This is an extension of the request for [System Time, please](https://community.glideapps.com/t/system-time-please/26837). There’s been a lot of questions for a while about how to get a universal time that can be shared for multiple users across multiple time zones. Most of you will know that any time your get a date/time from one of the glide special values, it will always be the user’s local time. But if you don’t know which time zone they are in, then you have no easy way to convert that date/time into something standard, like Greenwich Mean Time, to…

I customized Jeff’s solution to use in all my apps since this thread.

You can convert your user’s “now” to CET and then your problem will be solved.

---

<div class="post-metadata">

### Author: ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)
#### Post date: [July 30, 2021, 9:12am UTC](https://community.glideapps.com/t/is-it-possible-to-have-script-to-get-system-time-utc-or-gmt/29739/3 "2021-07-30T09:12:50Z")

</div>

Demo:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/6/9/6908eb5fc1fc8f6c46fa61a8002a48eb8c591f23.png)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/6/b/6b08d11acbaff00dc872b874df1404cd5179c65e.png)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/a/1/a1daa766e95876b45b782c92cbe8aac296fbf3b9.png)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/7/0/70aa388a3def8de204bfdc28d29dda3a5b3718cc.png)

```auto
(hour(CET)-hour(L))

+

(24
*
ABS(day(CET)-day(L))
/
(day(CET)-day(L)))

+

(minute(CET)-minute(L))/60

```

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/f/e/fe515357da34d2bc971b9f4362ea9ab5e3b33ee7.png)

```auto
L + (OS/24*-1)

```

However as it’s summer time I believe you can try CEST instead.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/d/3/d3986217b0e899e578cf78c9bb46ce8e20f7df5c.png)

---

<div class="post-metadata">

### Author: ![Mark\_Turrell](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mark_turrell/32/26605_2.png) [@Mark\_Turrell](https://community.glideapps.com/u/Mark_Turrell)
#### Post date: [July 30, 2021, 9:47am UTC](https://community.glideapps.com/t/is-it-possible-to-have-script-to-get-system-time-utc-or-gmt/29739/4 "2021-07-30T09:47:30Z")

</div>

Thanks - but I’m not sure if this helps. I don’t know the user offset time for all users. Plus I don’t always have the ability to get the user to do an action to pick up a timestamp I can manipulate (with a webhook - which I already use). The time for a user coming in and seeing the ‘closed’ popup is computed on the fly without a click.

Unless I’m missing something!

(And thanks for the clear explanation and walkthrough too 🌟🌟)

---

<div class="post-metadata">

### Author: ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)
#### Post date: [July 30, 2021, 10:03am UTC](https://community.glideapps.com/t/is-it-possible-to-have-script-to-get-system-time-utc-or-gmt/29739/5 "2021-07-30T10:03:49Z")

</div>

You don’t need the user to do anything for this to calculate. It is automatic. We take the “now” value from a math column, then the other things are template columns and math columns.

From your original post, do you mean you will show something to the user during 12-19 CET and something else during the off hours?

---

<div class="post-metadata">

### Author: ![Mark\_Turrell](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mark_turrell/32/26605_2.png) [@Mark\_Turrell](https://community.glideapps.com/u/Mark_Turrell)
#### Post date: [July 30, 2021, 10:27am UTC](https://community.glideapps.com/t/is-it-possible-to-have-script-to-get-system-time-utc-or-gmt/29739/6 "2021-07-30T10:27:07Z")

</div>

Yes - the system is open between 12 - 19 CET.  
But a user might come in from holiday in Peru… so -7 from CET

Let’s say it is 2000 in CET.  
User time for ‘now’ is 1300 Peru time.

I cannot just use a template column to pretend their time is CET. And the template column you have would compute the Time /CET Temp as user time (1300 CET). Which is wrong, as the Berlin user would see 2000 CET - which is the correct time.

Your offset counter does not work for the user. It is still processing 1300 CET… which is the wrong time. And then you are hardcoding the offset, but the offset would be different depending on the user time zone.

I solve the problem now by sending a webhook for a user action to Integromat. This then sends a CET timestamp to the User Profile table in GS. That helps for the some of my use cases, but it would be a ton easier to have this JS code to pick up the time 🙂 🙂 less time wasted moving data about (to Integromat and GS is super fast, from GS back to Glide… 15 seconds or much, much worse).

---

<div class="post-metadata">

### Author: ![Manu.n](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/manu.n/32/11679_2.png) [@Manu.n](https://community.glideapps.com/u/Manu.n)
#### Post date: [July 30, 2021, 10:40am UTC](https://community.glideapps.com/t/is-it-possible-to-have-script-to-get-system-time-utc-or-gmt/29739/7 "2021-07-30T10:40:14Z")

</div>

With YC

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/e/9/e948d2226d5008a1f821587e0ee9b428c8b8bf2d.png)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/2/3/23b21171721bede2c277d2c1743fb934fe17180c.png)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/1/3/136e2188e417a2cc42a0b9a3a7409161a6be4e3f.png)

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [July 30, 2021, 10:52am UTC](https://community.glideapps.com/t/is-it-possible-to-have-script-to-get-system-time-utc-or-gmt/29739/8 "2021-07-30T10:52:52Z")

</div>

> [@Mark\_Turrell](#):
>
> Unless I’m missing something!

yes, you are 😉

The beauty of Jeff’s solution is it requires _nothing_ from the user. It takes their “now” and through the use of a clever trick converts it to any (valid) time zone that you want.

---

<div class="post-metadata">

### Author: ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)
#### Post date: [July 30, 2021, 10:55am UTC](https://community.glideapps.com/t/is-it-possible-to-have-script-to-get-system-time-utc-or-gmt/29739/9 "2021-07-30T10:55:29Z")

</div>

Well if you insist…

Here’s a video to show that it works regardless of the user’s timezone. I even moved to Alaska for you.

The ‘pretend’ part here is to know if you use the current time of the user and add CEST to it then what would it convert to the user’s timezone. Glide can read that template and convert it to a datetime object.

Then we take the math column to find the offset compared to CEST and then a final math column to derive the true current CEST time.

Using this, you require nothing from the user and know their offset from a specific timezone, or in most of my cases, their timezone compared to UTC, and the “localized” time as the 4th column shows.

---

<div class="post-metadata">

### Author: ![Manu.n](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/manu.n/32/11679_2.png) [@Manu.n](https://community.glideapps.com/u/Manu.n)
#### Post date: [July 30, 2021, 10:59am UTC](https://community.glideapps.com/t/is-it-possible-to-have-script-to-get-system-time-utc-or-gmt/29739/10 "2021-07-30T10:59:18Z")

</div>

To make the YC column refresh, I tweaked the code a bit

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/f/5/f5749e9c4431d91084d92d242f9bf67c8b7be59d.png)

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/8/2/821c83f94b1d1135c1d9194505674ee732f60d19.png)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/5/6/564e972283fe2dd1d4deca88c4621f56d26c32ff.png)

---

<div class="post-metadata">

### Author: ![Manu.n](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/manu.n/32/11679_2.png) [@Manu.n](https://community.glideapps.com/u/Manu.n)
#### Post date: [July 30, 2021, 11:12am UTC](https://community.glideapps.com/t/is-it-possible-to-have-script-to-get-system-time-utc-or-gmt/29739/11 "2021-07-30T11:12:43Z")

</div>

Hello @Mark_Turrell

So you have the choice between 2 ways to do it  
Then it is possible to complete the script with other tips and tricks

---

<div class="post-metadata">

### Author: ![Uzo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/uzo/32/22639_2.png) [@Uzo](https://community.glideapps.com/u/Uzo)
#### Post date: [July 30, 2021, 12:05pm UTC](https://community.glideapps.com/t/is-it-possible-to-have-script-to-get-system-time-utc-or-gmt/29739/12 "2021-07-30T12:05:23Z")

</div>

You can use user address or current location switch to determine the time zone he is now and have a table to adjust the hours to any global time you want… if you are using my address picker… you already have a country as a last string after last coma, you can add to that script time zone value… that would be the best…because some countries have many time zones

---

<div class="post-metadata">

### Author: ![david](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/david/32/62831_2.png) [@david](https://community.glideapps.com/u/david)
#### Post date: [July 30, 2021, 4:32pm UTC](https://community.glideapps.com/t/is-it-possible-to-have-script-to-get-system-time-utc-or-gmt/29739/13 "2021-07-30T16:32:24Z")

</div>

We should just add UTC time as a special value.

---

<div class="post-metadata">

### Author: ![Mark\_Turrell](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mark_turrell/32/26605_2.png) [@Mark\_Turrell](https://community.glideapps.com/u/Mark_Turrell)
#### Post date: [July 30, 2021, 4:51pm UTC](https://community.glideapps.com/t/is-it-possible-to-have-script-to-get-system-time-utc-or-gmt/29739/14 "2021-07-30T16:51:33Z")

</div>

Agreed - and make it clear that there is a difference between UTC and user device time.

Thanks!

---

<div class="post-metadata">

### Author: ![Mark\_Turrell](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mark_turrell/32/26605_2.png) [@Mark\_Turrell](https://community.glideapps.com/u/Mark_Turrell)
#### Post date: [August 8, 2021, 7:39am UTC](https://community.glideapps.com/t/is-it-possible-to-have-script-to-get-system-time-utc-or-gmt/29739/15 "2021-08-08T07:39:09Z")

</div>

This is fixed now thanks to @Manu.n and his XC (Experimental Code) to pick up UTC as a value.

> [@Date Time UTC](https://community.glideapps.com/t/date-time-utc/29742):
>
> For those who are interested in dates, here is a small script to return the date and time in UTC. You must complete the Data parameters with the “The date / time at form submission” option so that the date and time update every 10 seconds.
