Date Time Issue

When I am printing now(), it's returning 9/8/2016 3:11 AM EDT.
But for hour(now()), it's returning: 7
totime(now()): 7:11 AM
Default user timezone is UTC-5:00(Eastern Time)
How do I get the correct hour for the present time?

OriginalPostID-233588

  Discussion posts and replies are publicly visible

Parents
  • Hi Vimals, This method works. I am able to extract the correct hour, however to change it back to date time, I am using the datetime() function and providing the hour I extracted before, but it is changing to a different value
    now():9/8/2016 4:26 AM EDT
    hour(totime(local(now()))):4
    datetime(year,month,day,hour,min,sec):9/8/2016 12:26 AM EDT
    local(datetime(year,month,day,hour,min,sec)):9/7/2016 8:26 PM EDT
    todatetime(local(datetime(year,month,day,hour,min,sec))):9/7/2016 8:26 PM EDT
Reply
  • Hi Vimals, This method works. I am able to extract the correct hour, however to change it back to date time, I am using the datetime() function and providing the hour I extracted before, but it is changing to a different value
    now():9/8/2016 4:26 AM EDT
    hour(totime(local(now()))):4
    datetime(year,month,day,hour,min,sec):9/8/2016 12:26 AM EDT
    local(datetime(year,month,day,hour,min,sec)):9/7/2016 8:26 PM EDT
    todatetime(local(datetime(year,month,day,hour,min,sec))):9/7/2016 8:26 PM EDT
Children
No Data