We are using skuid.moment.tz(skuid.time.getUserTimeZone()).format(); to get user date per timezone. But receiving below erorr:
Uncaught TypeError: Cannot read property ‘tz’ of undefined
On analysis further we found that skuid.moment is not getting loaded in some of users machine. We did not find anything related to browser. The machine were we are facing issues are MAC machines. Any help is greatly appreciated.
Atul,
Skuid only loads the moment.js library if the running user’s configured time zone is different from the user’s device / computer time zone. If the two time zones are the same, then Skuid does not load moment because browser-native Date libraries are sufficient to accurately render and format Datetimes.
Moreover, I think that you can use Skuid’s time API methods to achieve what you’re after, as Skuid’s time API methods will take time zone into account when formatting date times. The key API method you want to make use of to switch a Date to being in the running User’s configured Time Zone is skuid.time.getLocalDateTime( ). If you create a Date object in JavaScript, e.g. new Date(), and then pass this into skuid.time.getLocalDateTime(), you will get a Date object that is localized to the running User’s Time Zone.
Example: assume that the current time in EST is 2:34 PM. Let’s run the following code and see how its result differs based on the User’s configuration:
skuid.time.formatTime("h:m a", skuid.time.getLocalDateTime(new Date());
TEST 1
Computer Time Zone: America/New_York
User Time Zone: America/New_York
Output: “2:34 pm”
TEST 2
Computer Time Zone: America/New_York
User Time Zone: America/Los_Angeles
Output: “11:34 am”
TEST 3
Computer Time Zone: America/Los_Angeles
User Time Zone: America/New_York
Output: “2:34 pm”
TEST 4
Computer Time Zone: America/Los_Angeles
User Time Zone: America/Los_Angeles
Output: “11:34 am”
For more information, please see the skuid.time API documentation.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.