I have a google spreadsheet with a cell with my current time.
For example: Meeting at: 17:15
Is there a way, when a person from another computer and timezone opens the spreadsheet, that he can see the time in his current time zone.
Example: Meeting at: 2:15 pm.
Something like cell: =convertTime(17:15,"UTC +1) that automatically shows the 17:15 UTC+1 in your time zone?
Thanks
It's not possible to show different cell values to different users.
Google Sheets has a timezone setting for each spreadsheet but it hasn't a built-in fuction able to get the timezone of the current user. By the other hand custom function are executed anonymously so they will not be able to automatically get the current user timezone.
One option is to use Google Apps Script to create an user interface like a dialog or sidebar that use client-side code to show date / time value in the active user timezone.
Resources
https://developers.google.com/apps-script/guides/sheets
Related
I am attempting to build a live dashboard for our lovely mechanics to see how many services they have completed in a day. The majority of the time it will be used to only show services from a certain mechanic on today's date, however I would like to be able to change the date it shows date for and so would like to be able to grab that criteria from a certain cell in sheet.
My current thinking is that the dashboard would have a formula like this:
=COUNTIFS(
IMPORTRANGE(
"https://docs.google.com/spreadsheets/d/1bx65qPAChwZ8uxwJsMfh-w5uALdKVdnn8x7LXD6J3zs",
"Servicing!A:A"),
D1,
IMPORTRANGE(
"https://docs.google.com/spreadsheets/d/1bx65qPAChwZ8uxwJsMfh-w5uALdKVdnn8x7LXD6J3zs",
"Servicing!C:C"),
C7)
D1 is where i can put in the date. C7 is where the mechanics name is held. My thinking is that this is not working as the data is populated using a google form. This google form records a timestamp in the following way '3/13/2020 12:09:56' Meaning that It will only match this data if the exact same time matches. Is there a way to make it search for ALL records on a date instead of all from a precise time?
Thanks for reading!
I was able to remove the time from the google forms output by adding and extra column and using this formula
=TO_DATE(DATEVALUE(B805))
B805 is filled by the time stamp from the google form
I then made my formula search for the info in the new colum with the above in each cell. It worked! :)
I am trying to create an availability spreadsheet for people on a group google sheet, but we are all in different time zones. In order to avoid conversion confusion, I want to create a sheet that will auto adjust the cell data i.e. Ryan (who lives in the eastern time zone) says he is available on Monday from 5 to 10 PM. If Steve (who lives in the central timezone) looks at the sheet it will show that Ryan is available from 4-9 PM
I'm pretty sure that the answer to your question is that it's not possible without doing some cavalier sheet manipulation or linking spreadsheets. Basically with the exception of random numbers, cells have to calculate to the same result for all users. If both Steve and Ryan opened the sheet, the date/time displayed is the same for both viewers.
The time zone is set within the spreadsheet settings, which is actually a good thing (otherwise users would need to specify what timezone they were entering date values in by each cell).
Looking at your very brief use-case, I might consider making sheets by time zone and then create a button that views which user it is. Or possibly have a button that sets the sheets time zone based on user? There are lots of workarounds but not in the direct method you're asking for.
As I wrote this response, I got curious and made this google sheets concept that selects the time zone by user, if they are listed in Column J and their timezone in column K. It's not great as it requires a click, but if you make your own copy and maybe you can get some ideas.
Here's the code I used in the script editor:
/**
* #OnlyCurrentDoc
*/
const nUserCell = 'userCell';
var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
/**
* Returns the difference in minutes from spreadsheet from UTC.
*
*
* #return The Difference In Minutes
* #customfunction
*/
function getSheetTimeZone(){
var d = new Date();
return d.getTimezoneOffset();
}
function setUser(){
var theUser = Session.getActiveUser().getEmail();
ss.getRange(nUserCell).setValue(theUser);
}
I'm having a trouble when develop multiple timezones website.
Currently I'm storing time in UTC after some researches and it is working fine in most cases.
But there is one case that I couldn't find solution for it:
There are two kinds of user in two countries which are United States
and Thailand.
User in Thailand is worker (A).
User in US is manager (B).
When A starts working, their activities logged into our system and B
can watch those via a monitoring screen on web app and they can choose
the date on that.
Example user A starts working at 8 AM on 23 June with mobile
app, when B chooses 23 June date on the monitoring screen, they
can see the activities of user on Thailand on 23 June (because the results is queried by UTC time), but the
problem is he should see the activities on 22 June instead of 23
June because the time in Thailand is faster than United States 12
hours.
How can I show to user B activities of user A when he chooses the date 22 June?
You've not asked about any particular technology stack or implementation, so I can only answer from a general perspective.
Concepts worth understanding:
Thailand has a single time zone, which has an offset of UTC+7 all year.
The US has multiple time zones, whose offsets range from UTC-10 to UTC-4, depending on what part of the country you are referring to, whether or not daylight saving time is in effect, and whether or not a particular location observes daylight saving time. (Most of the country does, but all of Hawaii and much of Arizona does not.)
A "date" is just a year, month, and day on a calendar, but the time that which a date is observed is different depending on the time zone of the observer. There is a good visualization of this at everytimezone.com.
In your situation, you will have to decide the behavior you want depending on the specific needs of your application:
Do you want the period shown to represent all activities on the date as observed by the person choosing the date? If so, then determine the start of the current date and the start of the next date in the local time zone of the person selecting the date. Convert those to UTC, and query for all events in that UTC time range.
Example:
Example Activity Time: 2018-06-23T18:00:00+07:00 (Asia/Bangkok)
Stored as UTC: 2018-06-23T11:00:00Z
Date Selected: 2018-06-23 (America/New_York)
Local Range: [2018-06-23T00:00:00-04:00 , 2018-06-24T00:00:00-04:00 )
UTC Range: [2018-06-23T04:00:00Z , 2018-06-24T04:00:00Z )
Query: ... where ActivityUTC >= '2018-06-23 04:00:00' and ActivityUTC < '2018-06-24 04:00:00'
Or, do you want the date selected to always represent the date of the activity in the time zone of the person who recorded that activity, regardless of the time zone of the viewer? If so, then store that local date in a separate date-only column and just query on it without regard to time zone.
Example:
Example Activity Time: 2018-06-23T18:00:00+07:00 (Asia/Bangkok)
Local Date Stored: 2018-06-23
Date Selected: 2018-06-23
Query: ... where ActivityLocalDate = '2018-06-23'
Note, you might still store the UTC date and time in some other field, but it isn't relevant for this particular query.
From prior experience in the time and attendance industry, I can say that if it were me I would want the second option - as workers are typically paid based on their own time zones, not on those of their manager. However their are indeed edge cases and you'll have to decide for yourself which approach best matches your business requirements.
This Answer is specific to MySQL.
If you want B to see what A's clock says, use DATETIME; it will say 8AM.
If you want B to see A logging in in the middle of the night, use TIMESTAMP.
(This extends to A vs B, and to date as well as clock.)
Twice a year, DATETIME has a hiccup between 2AM and 3AM if there is a switch between standard and daylight-savings time.
In a Rails 4 app I want to use a function like this
#bill.trading_date = 6.hours.ago.to_date
to set the trading date for each user. Here are the steps I want to use.
I want to collect and save each users time zone to a database using something like time_zone_select.
I want to use the saved time zone to set the current DateTime for each user.
I want to set a trading date using the above function.
#bill.trading_date = 6.hours.ago.in_time_zone(<your time zone>).to_date
I have GWT application which uses Highstock JS library.
I'd like to implement following use case:
User select start and end dates and time from DateField and TimeField controls (GXT). These controls operate with java.util.Date values. I initialize end date by new Date() and start date by current date minus last hour. Controls display dates in user browser's timezone (e.g. GMT+4).
There is a control to select timezone to build chart: local or user defined.
I need to build Highstock chart in selected timezone. Data is stored in database in UTC.
Which settings, time adjustments I need to implement in order to display correct chart?
In general it is correct to use UTC for all timestamps and perform local changes according to user timezone or similar locally in your browser. If you set global.useUTC while creating your Highstock chart, all dates will be handled in UTC timezone.