What is the difference between gmt() and local()?

I have written

1. gmt(now(),"IST")

2. local(now(),"IST")

local() function shows correct time as per local timestamp, but gmt is showing +1 hour in my current time. Anyone can explain why?

  Discussion posts and replies are publicly visible

Parents
  • gmt function converts datetime into GMT and local function converts datatime into your profile timezone.

    gmt(now(),"IST") - gmt considers 1st parameter as datetime and 2nd parameter as its timezone. So as per here gmt takes now() datetime and IST as its timezone, converts into datetime with GMT timezone

    local(now(),"IST") - local considers 1st parameter as datetime and 2nd parameter as its timezone. So as per here gmt takes now() datetime and IST as its timezone, converts into datetime with your profile timezone

     

    Here in both the cases even-though now() has its own timezone which is neglected as both gmt() & local() takes only datetime as first parameter 

Reply
  • gmt function converts datetime into GMT and local function converts datatime into your profile timezone.

    gmt(now(),"IST") - gmt considers 1st parameter as datetime and 2nd parameter as its timezone. So as per here gmt takes now() datetime and IST as its timezone, converts into datetime with GMT timezone

    local(now(),"IST") - local considers 1st parameter as datetime and 2nd parameter as its timezone. So as per here gmt takes now() datetime and IST as its timezone, converts into datetime with your profile timezone

     

    Here in both the cases even-though now() has its own timezone which is neglected as both gmt() & local() takes only datetime as first parameter 

Children
No Data