🕒 System/GMT Time - Solved!

And also on my android phone

@Jeff_Hager I haven’t copied back and check, are you using the “medium” format to calculate the dates. I don’t know if changing to “short” solves all problems.

@ThinhDinh I’m using the short format for the values used in the calculation base on your recommendation. I’m not sure yet how to reproduce this. I started to change the region and time settings on my computer, but it may require a restart. I’ll try to take a look and figure out what’s going on.

@phong_tran just to make sure, have you refreshed the app to make sure you have the latest changes?

image

1 Like

I just went to the link you sent and now the difference is -17

1 Like

As of tonight, this broke. When the clocks changed something happened, and the North American date format no longer works. I have users in Europe who are fine (their format is 7, November, 2021 00:00).

I have an app that has relied on this code for 6 months and the app is suddenly useless. @Mark I know you don’t officially support this method, but is there any way to give us what we had before the times changed tonight? Having a way to get UTC is critical to the functioning of a community app that allows members to schedule worldwide. Is there any solution here? 400 users basically without an app in an instant. :disappointed:

1 Like

@John_Cabrera are you using the latest version of the math formula?
We uncovered an edge case about a month ago that caused it to fail around the end of each month.
Although your issue sounds like it’s different (related to a switch to daylight savings time?), it’s probably worth checking that you have the correct formula.

Update: Actually, @John_Cabrera I just realised that we do have another option now with the new Format Date plugin. All you need to do is pass that the users time with the Z format parameter, and it’ll return the users UTC offset.

4 Likes

Yeah, like @Darren_Murphy mentioned, I would give the new plugin a shot over my method. I haven’t tested it yet, but hopefully it works better.

Out of curiosity though, what exactly broke? I checked may app and my Offset value did update from -5 to -6 like I expected.

1 Like

I just replaced your method with the plugin method in 4 of my apps, and it seems to work perfectly :slight_smile:

2 Likes

@Jeff_Hager looks like I spoke too soon. The Format Date option appears to have stopped working :roll_eyes:

Screen Shot 2021-11-13 at 12.36.55 AM

Does it work for you? (I’m willing to bet that it does… but not my whole house :smiley: )

I am not Jeff but it is working for me. @Darren_Murphy

1 Like

Yep, that’s what I expected.

I’d also be willing to bet that it probably doesn’t work for @ThinhDinh. Or for @V88 either :wink:

1 Like

Haha I will check later but I have switched to the American formatting awhile ago so didn’t notice this when I first tried the column…

1 Like

Hasn’t worked for me since we spoke last about it!

1 Like

Can confirm, it’s not working if I change the browser language to Vietnamese.

1 Like

I’ve pretty much given up on a solution to this. Seems so simple. I just want to convert all user timestamped events into UTC so that I can sort entities like comments (not built in but my own creation) chronologically in apps where my users are globally distributed. How can it be such a pain?

I’m currently using a variation of this.

The only change I made was to negate the return value, as I’m converting from UTC to local time, so I need the local offset rather than the UTC offset. (If you read the docs for getTimezoneOffset, you’ll see it returns the difference between UTC and local - so it gives the UTC offset from local time, as opposed to the local offset from UTC time)

So I’m using:

return -(new Date().getTimezoneOffset())/60

I think that’s probably going to be the most reliable solution for now.

3 Likes

Will take a look for sure - cheers @Darren_Murphy

image

2 Likes