<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>The output of function hour(now()) is not  the hour of now() but the hour of gmt. Is this right?</title><link>https://community.appian.com/discussions/f/new-to-appian/25673/the-output-of-function-hour-now-is-not-the-hour-of-now-but-the-hour-of-gmt-is-this-right</link><description>Hello, 
 If the function hour(now()) is used, the output value is the &amp;quot;gmt hour&amp;quot; instead of now() time. 
 Is this right? 
 Then do I have to adjust the hour time by adding or subtracting time to make it match with my timezone? 
 
 https://docs.appian</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: The output of function hour(now()) is not  the hour of now() but the hour of gmt. Is this right?</title><link>https://community.appian.com/thread/100415?ContentTypeID=1</link><pubDate>Fri, 02 Sep 2022 00:26:48 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:4b81659d-6528-43f6-9c4b-471cf8134014</guid><dc:creator>dreamyoung</dc:creator><description>&lt;p&gt;Thank you!!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: The output of function hour(now()) is not  the hour of now() but the hour of gmt. Is this right?</title><link>https://community.appian.com/thread/100403?ContentTypeID=1</link><pubDate>Thu, 01 Sep 2022 13:59:15 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:3209d4b3-499f-49b3-a836-be7f834d397b</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Thanks for sharing your use case.&amp;nbsp; This is a good example of why that&amp;#39;s important: in your case, it&amp;#39;s probably better to have your expression rule just create the timestamp for the delay timer to fire, rather than doing all that math on the current time.&amp;nbsp; That&amp;#39;s what I&amp;#39;ve been able to do in the past while creating a rule that does essentially the same thing, i.e. &amp;quot;set expiration time to 2 AM the next morning&amp;quot;.&amp;nbsp; I&amp;#39;ll see if I can find my old expression rule code for this and share it here.&lt;/p&gt;
&lt;p&gt;Edit: I was able to find what I had done before and it&amp;#39;s fairly simple - basically just manually creating the timestamp like I said before; also I have it set up so that any time can be passed in as the &amp;quot;current&amp;quot; / &amp;quot;starting&amp;quot; time (allowing for better use case testing), and local variables abstract a lot of the initial functionality just for the sake of ease of understanding.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="java"&gt;a!localVariables(
  local!baseTime: a!defaultValue(ri!referenceTime, now()),
  
  local!newYear: year(local(local!baseTime) + 1), /* in case this rule is run on the last day of a year */
  local!newMonth: Month(local(local!baseTime) + 1), /* in case this rule is run on the last day of a month */
  local!newDay: Day(local(local!baseTime) + 1),
  
  local!targetHour: 00,
  local!targetMinute: 00,
  local!targetSecond: 01,

  
  userdatetime(
    local!newYear,
    local!newMonth,
    local!newDay,
    
    local!targetHour,
    local!targetMinute,
    local!targetSecond
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This example would return a value of 12:00:01 AM (12 am and 1 second) of the next day, in the user&amp;#39;s local time.&amp;nbsp; I personally usually set it up to fire at something more like 2 AM, just to avoid other things that fire off at exactly midnight (causing a spike of traffic on the environment around then), but that&amp;#39;s up to you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: The output of function hour(now()) is not  the hour of now() but the hour of gmt. Is this right?</title><link>https://community.appian.com/thread/100382?ContentTypeID=1</link><pubDate>Thu, 01 Sep 2022 01:06:54 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c46a64dd-7272-4e5c-b809-3d72853b4afb</guid><dc:creator>dreamyoung</dc:creator><description>&lt;p&gt;Thank you all.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I have solved&amp;nbsp;the problem by using the local() function&amp;nbsp;like hour(local(now(), &amp;quot;ROK&amp;quot;)) .&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:inherit;"&gt;For example,&amp;nbsp;I made an&amp;nbsp;expression rule.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:inherit;"&gt;When a specific task is currently performed, I want to delay until 12:00 AM the next day based on the current time.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:inherit;"&gt;( want the result to be like :&amp;nbsp; #&lt;span&gt;&lt;span class="CollapsibleOutputNode---print_value"&gt;/0#/2022 12:00 AM GMT+09:00&amp;nbsp;&lt;/span&gt;&lt;/span&gt;)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:inherit;"&gt;In this case, if hour(now()) is used, only gmt time is subtracted.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:inherit;"&gt;&lt;/span&gt;&lt;span style="font-family:inherit;"&gt;To calculate the time according to the timezone,&amp;nbsp;I had to subtract 9 in addition.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:inherit;"&gt;//------------------------------------------&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;= now() + intervalds(&lt;br /&gt; 23 - 9 - hour(now()),&lt;br /&gt; 59 - minute(now()),&lt;br /&gt; 60 - second(now())&lt;br /&gt;)&lt;/p&gt;
&lt;p&gt;&lt;span&gt;//------------------------------------------&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: The output of function hour(now()) is not  the hour of now() but the hour of gmt. Is this right?</title><link>https://community.appian.com/thread/100374?ContentTypeID=1</link><pubDate>Wed, 31 Aug 2022 12:01:24 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:6d386ef0-4c8a-4b0c-ad2d-ecb38058b7f2</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Instead of adding or subtracting anything, you should be able to simply use the &lt;em&gt;local()&lt;/em&gt; function.&amp;nbsp; This transforms the timestamp value in such a way that the time value (when extracted like with &lt;em&gt;hour()&lt;/em&gt;) will reflect your local time zone&amp;#39;s value instead of the GMT value.&amp;nbsp; It&amp;#39;s confusing but it works.&lt;/p&gt;
&lt;p&gt;And of course as Stefan already mentioned, we can probably provide better help if you actually explain your use case somewhat.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: The output of function hour(now()) is not  the hour of now() but the hour of gmt. Is this right?</title><link>https://community.appian.com/thread/100373?ContentTypeID=1</link><pubDate>Wed, 31 Aug 2022 09:29:23 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:bfd7c897-69dc-49ea-9f3a-57624c592027</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;Correct, but before starting to apply math, what is your use case? In my &amp;gt; 12 years I never had to do&amp;nbsp;this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>