Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
7 replies
Subscribers
7 subscribers
Views
2782 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
This may just be a UK specific question. Does anyone know why hour(no
steveb
over 8 years ago
This may just be a UK specific question.
Does anyone know why hour(now()) returns the GMT hour and not the BST hour and is there a way to get the correct (ie BST hour) ?
OriginalPostID-155590
OriginalPostID-155590
Discussion posts and replies are publicly visible
0
PhilB
A Score Level 1
over 8 years ago
Apologies if this is an obvious question, have you checked the internationalisation settings on the server?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Lakshmi Meyyappan
over 8 years ago
I don't know exactly why, but I believe the now() function only returns the GMT datetime. The system generally displays it in your local time, but when you take specific numbers like the hour then it is actually using the returned GMT datetime.
To correct it simply use hour(local(now())). Wrapping now() in local() will add the necessary datetime offset to the GMT datetime.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
PhilB
A Score Level 1
over 8 years ago
I don't believe that's the case at all. I've just run now() without local() and it returns 08/07/2015 13:18 GMT+01:00 - which is the BST value. The timezone under internationalization on the system tab) is set to (UTC) United Kingdom Time (Europe/London).
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Lakshmi Meyyappan
over 8 years ago
What is your user's timezone setting? I changed my user's time zone a couple of times and watched the now() function change what it returned. This backs up my theory that the now() function actually returns only the GMT value, but Appian is set up to display datetimes in the user's time zone so the now() result is displayed as such. If you want Appian to always use the time zone set on the internationalization tab then there is a checkbox on that tab to "Always overrude users' selected time zone"
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Lakshmi Meyyappan
over 8 years ago
But even checking that box will still return the GMT value from now(), it will just be displayed differently. Using local() adds an offset to change the actual datetime value rather than just it's display. If you run local(now()) then it actually looks wrong because the datetime is returned in your time zone and then Appian tries to display it in your time zone again. But the underlying value is what you need to use in order to perform operations on it such as hour()
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Tim
Certified Lead Developer
over 8 years ago
Have a good read of this!
forum.appian.com/.../Date_and_Time_Functions.html
It's a complicated structure depending on what you're trying to do. There are functions such as local() and offsetfromGMT() that allow you to calculate date/time values in various circumstances.
Also check your installation server, is it set to GMT and/or to adjust for daylight savings? You will also need to check your timezone settings in the JBoss boot script.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
steveb
over 8 years ago
Thanks for the advice.
Our internationalisation setting is set to UK time.
Wrapping now() in local() before using hour() is giving the right answer so will use this method.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel